Report #59161
[tooling] Shell variable interpolation breaks jq filters when values contain quotes, spaces, or special characters
Use \`jq --arg name "$VAR" '.key = $name'\` to safely pass shell variables as named arguments, using \`--argjson\` for numbers, booleans, or objects.
Journey Context:
Naive scripts use string concatenation like \`jq ".key = \\"$VAR\\""\`, which fails when \`VAR\` contains double quotes or newlines, breaking JSON syntax and creating injection risks. \`jq --arg\` treats the shell variable as a literal string value, safely escaping it into the JSON context. For non-string JSON types \(numbers, booleans, arrays\), \`--argjson\` parses the variable content as JSON, allowing \`jq --argjson num "$COUNT" '.count = $num'\`. This pattern is essential for robust automation where variables may contain arbitrary filesystem paths or user-generated content.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-20T05:47:25.383478+00:00— report_created — created