Skip to content

fix(terraform-vault): a missing CA bundle is empty, not the string "null" - #180

Merged
patrick-hermann-sva merged 1 commit into
mainfrom
fix/terraform-vault-jq-null
Sep 9, 2026
Merged

fix(terraform-vault): a missing CA bundle is empty, not the string "null"#180
patrick-hermann-sva merged 1 commit into
mainfrom
fix/terraform-vault-jq-null

Conversation

@patrick-hermann-sva

Copy link
Copy Markdown
Contributor

#178 made vault_ca_bundle conditional on the file being non-empty. It still went out, because the file is never empty:

CA=$(jq -r '.vault_ca_bundle' /tmp/rendered-secrets.json)

On a missing key jq -r prints the four-character string null, not nothing. So /tmp/vault_ca_bundle contains null, every emptiness test sees a non-empty file, and null gets passed to terraform as the CA bundle — reproducing the exact error #178 set out to fix:

Error: Value for undeclared variable
A variable named "vault_ca_bundle" was assigned on the command line

Demonstrated rather than assumed:

$ echo '{"a":1}' | jq -r '.vault_ca_bundle'          | cat -A
null$
$ echo '{"a":1}' | jq -r '.vault_ca_bundle // empty' | cat -A
                                                     ← nothing

Also guards the mask: ::add-mask:: on an empty value is a no-op warning, and on the old path it was registering the word "null" as a secret to redact from every log line.

🤖 Generated with Claude Code

https://claude.ai/code/session_01K2rfvVDXWjWZAKMcpwvgLG

…ull"

#178 made vault_ca_bundle conditional on the file being non-empty. It still
went out, because the file is never empty: on a MISSING key `jq -r` prints the
four-character string "null", not nothing.

So /tmp/vault_ca_bundle contained "null", the -s test saw a non-empty file, and
"null" was passed to terraform as the CA bundle -- reproducing the exact error
#178 set out to fix.

`// empty` makes a missing key yield nothing, which is what every caller here
already assumed it did.

Also guards the mask: ::add-mask:: on an empty value is a no-op warning, and on
the old path it registered the word "null" as a secret to redact from every log
line.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01K2rfvVDXWjWZAKMcpwvgLG
@patrick-hermann-sva
patrick-hermann-sva merged commit 83b51ae into main Sep 9, 2026
2 checks passed
@patrick-hermann-sva
patrick-hermann-sva deleted the fix/terraform-vault-jq-null branch September 9, 2026 12:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant