fix(gcp-secret-get): handle multiline field values (jwt_key) - #35
Merged
Conversation
…redoc form The naive NAME=value append corrupts $GITHUB_ENV the moment a field's value contains an embedded newline -- jwt_key is a multi-line PEM. Every field now goes through the NAME<<DELIM / value / DELIM form with a random per-field delimiter, and each non-empty line of a value is masked individually rather than masking the whole multi-line blob as one token (log masking matches per line). Caught by the second real end-to-end run of sf-org-login's gcp branch: the prior export_to_environment fix got past the empty-secret guard, but the JWT login step then rejected the decoded key with "not a PEM private key" -- verified locally that this fix produces the exact documented GITHUB_ENV multiline format before pushing.
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.
Summary
NAME=valueappended to$GITHUB_ENV. That format is only valid for single-line values —jwt_keyis a multi-line PEM, so writing it that way corrupted$GITHUB_ENV(subsequent lines got parsed as bogus separate declarations).$GITHUB_ENV's documented multiline heredoc form (NAME<<DELIM/ value /DELIM) with a random per-field delimiter, uniformly for all fields (simpler than branching on single- vs multi-line).::add-mask::on each non-empty line of a value), since log masking matches per line — masking a multi-line blob as one token wouldn't reliably redact its individual lines elsewhere in the log.$GITHUB_ENVmultiline format before pushing.Second bug from the same live run that caught #34 (
export_to_environment) — that fix got past the "secret is empty" guard, then the JWT login step rejected the decoded key with "not a PEM private key". This is the actual root cause.Test plan
actionlintcleanSECRET_JSON, confirmed exactNAME<<DELIM/value/DELIMoutputnpm run all— unaffected, all green via pre-push hooksetup-external-app.ymlagainstdevhubonce this lands and@v2moves🤖 Generated with Claude Code