Conversation
Contributor
🔍 Rendered manifest diff — this PR vs
|
cmd_seed ran seed_body | store_create for each key. GCP's store_create creates the Secret Manager secret, then adds a version from stdin -- two calls -- and AWS's buffers stdin into a temp file before its one create-secret call. Either way, a failing or empty seed_body still let store_create run: a version-less secret on GCP, or one holding an empty string on AWS. set -o pipefail doesn't catch this -- pipefail reports the pipeline's rightmost failing command, so a failing seed_body piped into a succeeding store_create reports success. Worse, store_has then sees the secret on every later run and skips it, so the entry stays broken forever. Capture seed_body's output into a variable first, check it is non-empty and that seed_body succeeded, and only then call store_create with the value on stdin. On failure, report which key failed (never the value) and continue to the next entry, tallying a failed count -- matching cmd_grant's existing per-key convention -- and make cmd_seed's own exit status reflect it.
Smana
force-pushed
the
fix/secret-store-seed-empty-version
branch
from
September 29, 2026 16:42
8641275 to
7c08974
Compare
This branch has not been deployed
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.
The bug
secret-store.sh seed'scmd_seedran, for every generatable key:store_createruns unconditionally regardless of whetherseed_bodyproduceda good value:
store_createfirst runsgcp_sm create(creates the SecretManager secret), then
gcp_sm versions add --data-file=-(reads the valuefrom stdin). If
seed_bodyfailed or printed nothing, the secret iscreated anyway, then gets a version-less or empty add.
store_createbuffers stdin into a 0600 temp file, then callscreate-secret --secret-string file://...in one call. Ifseed_bodyfailed or printed nothing, the secret is still created, holding an empty
string.
set -o pipefaildoes not catch this: pipefail reports the pipeline's exitstatus as the rightmost failing command. If
seed_bodyfails butstore_createitself exits 0, the pipeline reports success. Only whenstore_create's own calls eventually fail (e.g. GCP'sversions addrejecting an empty payload) does
errexitabort the run -- by which pointthe broken secret already exists.
Failure scenario
cnpg-xplane-zitadel-superuser, whose body is derivedfrom
zitadel-envvars(not generated).zitadel-envvarshasn't beenseeded yet, so the derive step fails.
store_hasnow finds the secret present and skips itforever -- the entry never self-heals, even after
zitadel-envvarsisseeded.
The fix
cmd_seednow capturesseed_body's output into a variable first, checksthat the command succeeded and produced a non-empty value, and only then
pipes that value into
store_createon stdin (never on argv -- unchangedfrom before). On failure it reports
[FAILED ] <key>(never the value),increments a
failedcounter, and continues to the next entry -- the sameper-key report-and-continue convention
cmd_grantalready uses -- withcmd_seed's own exit status now reflecting whether any entry failed.AWS's
store_createwas checked per the review note: it has the same defectshape (create runs regardless of a bad payload), just folded into one call
instead of GCP's two, so the same outer guard fixes it too. No change was
needed inside
store_createitself.Gates
bash scripts/ci/tests/test-secret-store-seed.sh(new, TDD)[created] test-keydespite a failing/emptyseed_body), passes against the fixbash scripts/ci/tests/test-no-secret-argv.shshellcheck -x -S warning scripts/provision/secret-store.shtask checkvector, unrelated), 0 failedNot a draft -- ready for review, not for merge.