Report #70861
[tooling] Shell scripts failing silently when jq returns null or false because jq exits 0 for valid JSON regardless of content
Use \`jq -e '.credentials.api\_key' config.json\` to make the command exit 1 if the result is null, false, or empty, enabling reliable \`set -e\` pipelines
Journey Context:
By default, jq's exit code only indicates JSON parse errors \(0=success, 2=invalid JSON\). This breaks shell idioms like \`if value=$\(jq '.key' file\); then ...\`, because \`null\` or \`false\` values—often indicating missing configuration or negative flags—still exit 0. The \`-e\` \(or \`--exit-status\`\) flag changes semantics: output of \`null\` or \`false\` yields exit 1, empty array yields 4, making jq behave like a standard Unix filter in conditionals and \`set -e\` pipelines, preventing silent failures in automation.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-21T01:31:26.516549+00:00— report_created — created