warpdotdev/warp · error

Invalid data: {err}

Error message

Invalid data: {err}

What it means

When a jq filter is applied to command output, the input stream must be valid JSON; this error comes from jaq's invalid-input callback — the data fed to the filter failed to parse. It is an input problem, not a filter problem (compare the separate jq filter error).

Source

Thrown at app/src/ai/agent_sdk/output.rs:216

    let input_result = serde_json::from_value::<Val>(value);

    let runner = Runner {
        null_input: false,
        color_err: false,
        writer: Writer {
            format: Format::Json,
            pp: pretty_pp(),
            join: false,
        },
    };

    jaq_all::data::run(
        &runner,
        jq_filter,
        Default::default(),
        [input_result].into_iter(),
        // Callback to format invalid input errors.
        |err| anyhow::anyhow!("Invalid data: {err}"),
        // Callback to handle filter outputs.
        |result| match result {
            Ok(val) => write_filter_output(&val, out),
            Err(err) => anyhow::bail!("jq filter error: {err}"),
        },
    )?;

    Ok(())
}

/// Pretty-printer configuration used for non-scalar filter output. Matches
/// `serde_json`'s pretty printer: two-space indent, space after `:`, no
/// trailing space after `,` (since commas sit at end-of-line).
fn pretty_pp() -> jaq_write::Pp {
    jaq_write::Pp {
        indent: Some("  ".to_string()),
        sep_space: true,
        ..jaq_write::Pp::default()

View on GitHub (pinned to e72fd7aacb)

Solutions

  1. Run the same command without --jq and inspect the raw output
  2. Ensure the underlying command succeeded (check exit code) before filtering
  3. Keep stderr out of the filtered stream (2>/dev/null) so only the JSON payload reaches the filter
  4. Fix the generating command so stdout carries pure JSON

Example fix

# before
warp task list --jq '.[0].id' 2>&1 | tail -n 1   # stderr pollutes JSON

# after
warp task list --jq '.[0].id' 2>/dev/null
Defensive patterns

Strategy: validation

Validate before calling

# Validate the payload is JSON before applying any filter
raw=$(warp task list 2>/dev/null) || { echo 'command failed; skipping filter' >&2; exit 1; }
printf '%s' "$raw" | jq empty 2>/dev/null || { echo 'output is not JSON' >&2; exit 1; }
printf '%s' "$raw" | jq '.[0].id'

Try / catch

out=$(warp task list --jq '.[0].id' 2>&1) || { case "$out" in *'Invalid data:'*) warp task list 2>/dev/null | jq '.[0].id';; *) echo "$out" >&2; exit 1;; esac; }

Prevention

When it happens

Trigger: Combining --jq with output that is not valid JSON: warnings or log lines interleaved into stdout, an empty output stream, or a command that emits human-readable text (e.g. an error message) while the filter expects JSON.

Common situations: Merging stderr into stdout with 2>&1 before filtering; log noise printed ahead of the JSON payload; using --jq on a failed command's text output; upstream schema changes making output non-JSON.

Related errors


AI-assisted analysis of warpdotdev/warp@e72fd7aacb (2026-08-16). Data as JSON: /api/errors/90f0d0da23fd3342. Report an issue: GitHub.