{"record":{"id":"649c9521edbe07b7","repo":"warpdotdev/warp","slug":"jq-filter-error-err","errorCode":null,"errorMessage":"jq filter error: {err}","messagePattern":"jq filter error: (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"app/src/ai/agent_sdk/output.rs","lineNumber":220,"sourceCode":"        color_err: false,\n        writer: Writer {\n            format: Format::Json,\n            pp: pretty_pp(),\n            join: false,\n        },\n    };\n\n    jaq_all::data::run(\n        &runner,\n        jq_filter,\n        Default::default(),\n        [input_result].into_iter(),\n        // Callback to format invalid input errors.\n        |err| anyhow::anyhow!(\"Invalid data: {err}\"),\n        // Callback to handle filter outputs.\n        |result| match result {\n            Ok(val) => write_filter_output(&val, out),\n            Err(err) => anyhow::bail!(\"jq filter error: {err}\"),\n        },\n    )?;\n\n    Ok(())\n}\n\n/// Pretty-printer configuration used for non-scalar filter output. Matches\n/// `serde_json`'s pretty printer: two-space indent, space after `:`, no\n/// trailing space after `,` (since commas sit at end-of-line).\nfn pretty_pp() -> jaq_write::Pp {\n    jaq_write::Pp {\n        indent: Some(\"  \".to_string()),\n        sep_space: true,\n        ..jaq_write::Pp::default()\n    }\n}\n\n/// Write a single filter output, unwrapping top-level scalars to raw text.","sourceCodeStart":202,"sourceCodeEnd":238,"githubUrl":"https://github.com/warpdotdev/warp/blob/e72fd7aacbbb2236d9b3be2aad7e7178fe94b4bc/app/src/ai/agent_sdk/output.rs#L202-L238","documentation":"The jq filter parsed successfully but failed at runtime against actual input values (jaq's result callback): indexing into a scalar or null, calling a function on the wrong type, or arithmetic on strings. The filter is syntactically valid — the input shape does not match what it assumes.","triggerScenarios":"A filter like `.config.name` where some input rows lack `config` or carry a non-object there; `.foo[0]` when `.foo` is null; heterogeneous list output where fields are optional per row.","commonSituations":"Filters tested on one sample row then run over the full list; optional fields present on some objects only; schema changes between CLI versions adding/removing keys.","solutions":["Make the filter defensive: optional access (.config.name?), // alternatives, or try/catch","Inspect the unfiltered output to learn the actual shapes","Pin the filter to fields present on every row, or project with map(.id?)","Rehearse the filter with jq locally against a saved sample before scripting it"],"exampleFix":"# before\nwarp runner list --jq '.[].config.name'\n\n# after\nwarp runner list --jq '[.[] | .config.name? // \"(unnamed)\"]'","handlingStrategy":"validation","validationCode":"# Rehearse the filter against a saved sample before using it in scripts\nwarp runner list > /tmp/sample.json 2>/dev/null\njq '[.[] | .config.name? // \"(unnamed)\"]' /tmp/sample.json >/dev/null && echo filter-ok","typeGuard":".config as $c | ($c | type) == \"object\" and ($c | has(\"name\"))","tryCatchPattern":"out=$(warp runner list --jq '.[].config.name' 2>&1) || { case \"$out\" in *'jq filter error:'*) warp runner list --jq '[.[] | .config.name?]';; *) echo \"$out\" >&2; exit 1;; esac; }","preventionTips":["Use optional access (.foo?) and // defaults for fields that may be absent","Test filters against real, heterogeneous samples — not one happy-path row","Pin filters to fields documented as always-present"],"tags":["jq","filter","type-error","output"],"backgroundTag":null,"analyzedSha":"e72fd7aacbbb2236d9b3be2aad7e7178fe94b4bc","analyzedAt":"2026-08-16T08:27:25.381Z","schemaVersion":2},"datasetVersion":"2026-08-16T13:17:31.715Z"}