Repository navigation
fix(cli): fail when --secrets-file can't be read or parsed - #67
Merged
Merged
Conversation
A missing or unparsable --secrets-file was ignored: up,
run-user-commands and build ran with no secrets injected or masked and
could exit 0.
As the reference CLI's readSecretsFromFile, the file is now read once,
before anything else, and a failure ends the command with
{"outcome":"error","message":<Node's fs error or "Invalid json
data">,"description":"Failed to read/parse secrets"} and exit 1. The
file is parsed as jsonc.parse does: comments and any JSON value are
accepted, and trailing commas, a BOM and trailing data are not. Values
become env vars as JS String() makes them, in JS key order. build,
whose --secrets-file the reference lacks, fails the same way.
Eight hermetic parity cases compare the error and acceptance paths
with the reference for up and run-user-commands.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Order a secrets object's keys with the Features package's JS object instead of a second copy of the array-index rules, write -0 as "0" as String() does, and leave empty strings out of the values to mask, as replaceAllLog's length filter does. Pin array-index boundaries, number formatting and masking by length with cases computed by node from the reference's jsonc-parser. 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.
Problem. A missing or unparsable
--secrets-filewas ignored:up,run-user-commandsandbuildran with no secrets injected or masked and could exit 0. (buildwith a Dockerfile did fail, but with a different message, and its Feature build dropped the secrets.)Reference (TS
readSecretsFromFile). It throwsContainerError({description: 'Failed to read/parse secrets'});upandrun-user-commandsthen print an error result and exit 1, before looking for the configuration.Now (Go = TS)
{"outcome":"error","message":"ENOENT: no such file or directory, open '<path>'","description":"Failed to read/parse secrets"}, exit 1. Other read errors use Node's wording."message":"Invalid json data".jsonc.parse: comments and any JSON value are accepted; trailing commas, a BOM, an empty file, trailing data and unquoted keys are rejected. I checked these against jsonc-parser 3.3.1.String()makes them, in JS key order.Object.values(...).filter(v => v.length), including TS's failure on anullvalue.build --secrets-file(Go-only) fails the same way;docs/go-only-features.mdsays so.Tests
upandrun-user-commands): missing, invalid JSON, JSONC with non-string values, null value. 6 fail with the pre-change binary; the 2 JSONC cases also passed before, because the file was silently dropped.secrets_cmd_test.go: exact output and exit code for the three commands.secrets_held_test.goandsecrets_repo_held_test.goasserted nil for a missing file and bad JSON, which codified the bug; they now assert the error contract.Known remaining differences (unchanged): a non-string secret with
--dotfiles-repositorycrashes TS (quoteValue) and not Go; a top-level string is split by rune, not by UTF-16 unit. Separately, secrets vsremoteEnvprecedence (TS lets secrets win) will be a follow-up PR.Validation (local)
task lint,task spec:compliance: pass.task test:racewithTMPDIRoutside/tmp: pass.task parity:contract: only the 2 known/tmp/.gitcases fail.TestE2E_UpSecretsFile: pass.PARITY_COMMAND=up task parity:runtime: the 8 new cases pass. The failing cases,up.workspace-secrets-successamong them, fail identically onmainon this machine: Go treats/tmpas a git root because of a stray/tmp/.git, which changesremoteWorkspaceFolder. CI is the check for those.🤖 Generated with Claude Code