Report #12943
[tooling] Shell variables with special characters break jq queries when using string interpolation
Use jq --arg name "$variable" '. \+ \{key: $name\}' to safely pass shell variables into jq; use --argjson for numbers, booleans, or null
Journey Context:
Developers often interpolate shell variables directly into jq filter strings. This fails when variables contain quotes, newlines, or backslashes, leading to syntax errors or injection vulnerabilities. The --arg flag passes the value as a jq variable that is automatically JSON-escaped, handling all edge cases safely. --argjson is required for non-string values \(numbers, booleans, null\) since --arg always treats the input as a literal string. This pattern completely eliminates shell escaping bugs when passing dynamic data to jq.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-16T17:21:04.252122+00:00— report_created — created