Repository navigation
fix(builder): skip runtime resolution for a forced-native build - #24
Closed
duplo-darren wants to merge 1 commit into
Closed
duplo-darren wants to merge 1 commit into
duplo-darren wants to merge 1 commit into
Conversation
RUNTIME=podman in .env breaks every containerized extension build, regardless of extension — reported with a full root-cause trace and a live rebuild confirming both the failure and the fix. build-extension.sh re-invokes itself inside the builder container to do the actual dotnet/npm work. docker-compose.yml's builder service sets DUPLO_BUILD_NATIVE=1 in its environment for exactly this re-entrant call — nesting a container runtime inside the build container isn't supported, and builder_mode() already has a documented branch for it. But builder_dispatch() called runtime_resolve unconditionally, before ever checking DUPLO_BUILD_NATIVE. Since the whole repo (.env included) is bind-mounted into the container at /work, the inner invocation's _envv lookup read RUNTIME=podman straight off the mounted file, runtime_requested() returned non-empty, and the fallback treated that as an explicit pin and fataled — before builder_mode()'s want_native=1 short-circuit ever got evaluated. RUNTIME=docker, the default, usually masks this: docker is typically also on the host's PATH, so the same resolve call that should be skipped happens to succeed by accident. Same latent bug either way. Fix: guard the runtime_resolve call with the already-computed want_native flag, so a forced-native build — which the container always is — skips runtime resolution entirely instead of racing it. No behavior change on the host-side (outer) dispatch, where want_native is unset by default and the existing resolve-or-die logic still runs. Verified both ways: reproduced the exact reported error in isolation against the unpatched code (same message, same exit 1), confirmed the fix resolves it, and confirmed the host-side path — a developer who names a runtime they genuinely don't have — still fatals correctly rather than silently going native. Also verified end-to-end: rebuilding extensions/soc2-posture-extension with RUNTIME=podman set succeeds after the fix, fails identically before it. Tests: 5, new file (none existed for _builder.sh before). Confirmed RED against the unpatched code — exactly the forced-native/unresolvable-RUNTIME case fails, nothing else — then GREEN with the fix. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Author
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Bug
RUNTIME=podmanin.envbreaks every containerized extension build, regardless of extension.Repro:
RUNTIME=podmanin.env(the macOS example indocs/configuration.mdanddocs/getting-started/prerequisites.md)../scripts/build-extension.sh extensions/<any>.Observed:
This fires after the builder container is created — podman successfully launches it, then the build fails inside.
Root cause
build-extension.shre-invokes itself inside the builder container to do the actual dotnet/npm work.docker-compose.yml'sbuilderservice setsDUPLO_BUILD_NATIVE=1in its environment for exactly this re-entrant call — nesting a container runtime inside the build container isn't supported, andbuilder_mode()already has a documented branch for it.But
builder_dispatch()calledruntime_resolveunconditionally, before ever checkingDUPLO_BUILD_NATIVE. The whole repo —.envincluded — is bind-mounted into the container at/work, so the inner invocation's_envvlookup readsRUNTIME=podmanstraight off the mounted file,runtime_requested()returns non-empty, and the existing fallback treats that as an explicit pin and fatals — beforebuilder_mode()'swant_native=1short-circuit ever gets evaluated.RUNTIME=docker, the default, usually masks this: docker is typically also on the host's PATH, so the same resolve call that should be skipped happens to succeed by accident. Same latent bug either way.Fix
Guard the
runtime_resolvecall with the already-computedwant_nativeflag, so a forced-native build — which the container always is — skips runtime resolution entirely instead of racing it:No behavior change on the host-side (outer) dispatch, where
want_nativeis unset by default and the existing resolve-or-die logic still runs.Verification
Reproduced the exact reported error in isolation against the unpatched code (same message, same exit 1), confirmed the fix resolves it, and confirmed the host-side path — a developer who names a runtime they genuinely don't have — still fatals correctly rather than silently going native.
Also verified end-to-end: rebuilding
extensions/soc2-posture-extensionwithRUNTIME=podmanset succeeds after the fix, fails identically before it.Testing
New file — none existed for
_builder.shbefore. 5 tests, confirmed RED against the unpatched code (exactly the forced-native/unresolvable-RUNTIMEcase fails, nothing else), then GREEN with the fix. Full suite: 137 assertions across 8 files, all passing.🤖 Generated with Claude Code