Report #14675
[tooling] Shell variables break when passed into jq queries
Use \`jq --arg name "$value" '.key = $name'\` to safely pass shell variables as jq variables; prevents injection and handles spaces/special characters correctly.
Journey Context:
The naive approach uses shell interpolation: \`jq ".key = \\"$value\\""\`, which breaks on quotes, spaces, and newlines, and is vulnerable to injection. \`--arg\` \(and \`--argjson\` for numbers/booleans/arrays\) binds the shell variable to a jq variable safely before query execution. This is the only robust way to integrate jq into shell pipelines processing untrusted data. \`--slurpfile\` is the variant for reading entire files into variables.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-16T22:12:34.755311+00:00— report_created — created