Repository navigation
fix(cli): match TS secrets precedence and --remove-existing-container failure - #73
Merged
Merged
Conversation
The reference runs every lifecycle hook with {...remoteEnv, ...secrets},
where remoteEnv is the probed env, then --remote-env, then the config's
remoteEnv. up and run-user-commands put the secrets before both remoteEnv
sources, so a remoteEnv entry of the same name hid the secret.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
up ignored the error removing the existing container and went on. The
reference fails up with "An error occurred setting up the container."
and the message "Command failed: <docker> rm -f <id>" (with the
container ID for a Compose configuration), exit 1. The removal is now
logged as the reference's start/stop pair, "Removing Existing Container"
("Removing existing container." for Compose), instead of an info line.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
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.
Two drifts from the reference Dev Container CLI v0.90.0.
1.
--secrets-filevalues vsremoteEnvTS: every lifecycle hook runs with
{ ...remoteEnv, ...secrets }(injectHeadless.tsrunLifecycleCommand), whereremoteEnvisprobeRemoteEnv's{ ...shellEnv, ...params.remoteEnv, ...config.remoteEnv }. Precedence, lowest to highest: probed env,--remote-env, configremoteEnv, secrets. This applies toupandrun-user-commands(dotfiles also get{ ...remoteEnv, ...secrets }).execandset-uptake no secrets file.--remote-envand the config'sremoteEnv, so either one hid a secret of the same name.hookRemoteEnvin up.go andlifecycleRemoteEnvin run_user_commands.go) are now one,hookRemoteEnv(probed, remoteEnvs, cfgRemoteEnv, secrets).set-uppasses no secrets, as before.2.
up --remove-existing-containerTS:
findExistingContainer(singleContainer.ts) andopenDockerComposeDevContainer(dockerCompose.ts) wrapremoveContainerinoutput.start/output.stopwith the textRemoving Existing Container(Compose:Removing existing container.). A failure rejects withCommand failed: <docker> rm -f <id>, which the setup catch turns intoContainerError("An error occurred setting up the container."). It carries the container ID only for Compose, wherecontaineris already assigned.upprints the error JSON and exits 1.Removing existing container <id>..., ignored the removal error (_ = …), and went on.upwith the same error JSON and exit 1. The engine error stays wrapped forerrors.Is/As.Tests
TestHookRemoteEnvOrdersLaterSourcesLast(updated): a secret beats--remote-envand the config'sremoteEnvof the same name, and the config'sremoteEnvbeats--remote-env. ReplacesTestLifecycleRemoteEnvOrder, whose function was folded in. Before this change both tests asserted the old order.TestRemoveExistingContainer: for image and Compose configs, success emits the start/stop pair. Failure emits only start and returns the TS error output (message, description,containerIdonly for Compose,--docker-pathhonored), wrapping the daemon error.up.secrets-override-remote-env-successandrun-user-commands.secrets-override-remote-env-success: a hook printsTOKEN(set by secrets,--remote-env, and config remoteEnv) andCONFIG_WINS(set by--remote-envand config remoteEnv). Against an origin/main binary both cases fail withconfig/configvs TSSecretValue1/config. With this change both match.--docker-pathwrapper cannot make only Go's removal fail. The unit test covers it.Checks (all run from the branch worktree)
go build ./...: okgo tool task lint: okBASE=origin/main go tool task mutate: 3 refused, 0 survivedTMPDIR=/var/tmp/<unique> go tool task test:race: okgo tool task parity:contract: 114 matched. The 2 failures,read-configuration.features-configuration-local-feature-{key-order,metadata}-success, come from a stray/tmp/.giton the dev machine and are unrelated.go tool task test:e2e: okPARITY_COMMAND=up,run-user-commands go tool task parity:runtime: 109 matched, 22 failed, 4 arm64 skipped. Locally the stray/tmp/.gitchangesremoteWorkspaceFolderfor workspaces under/tmp:/tmpsymptom, plusup.compose-with-name-success).up.image-reuses-base-image-successalso passed when rerun alone.up.compose-without-workspace-folder-uses-root-successis flaky on both binaries. The TS and Go sides share a Compose project name, and Go sometimes finds the TS side's container while it is being removed ("container is marked for removal"). It reproduces with the origin/main binary./tmpsymptom here. With their workspace moved to/var/tmpthey match, and they fail against origin/main as described above.🤖 Generated with Claude Code