Skip to content

fix(jq): follow jq's input stream, per-file names and per-input errors - #2592

Merged
chaliy merged 1 commit into
mainfrom
claude/project-thread-1mku65
Oct 7, 2026
Merged

chaliy merged 1 commit into
mainfrom
claude/project-thread-1mku65

Conversation

@chaliy

@chaliy chaliy commented Oct 7, 2026

Copy link
Copy Markdown
Contributor

Requested by Михайло · project thread

What changed

The jq builtin now handles input the way jq 1.7/1.8 does:

  • The filter runs on a shared, lazily consumed input stream, so input and inputs pull the next values. With -n, the filter runs once on null and the whole stream goes to input/inputs. When the stream is empty, input fails with "No more inputs".
  • Each file is read on its own. A missing file prints jq: error: Could not open file X: ..., the other files are still processed, and the exit code is 2.
  • A runtime error on one input prints jq: error (at <stdin>:N): ... (or file:N) and processing continues with the next input. The exit code is 5.
  • A JSON parse error part way through still outputs the values that came before it.
  • error("msg") prints unquoted. A non-string thrown value prints (not a string): <json>.
  • -e exit status follows the last output.
  • -s on empty input gives [].

Why

Adopted from the pseudo-linus Debian oracle bench, where these were the most common jq mismatches against real jq.

Before

$ jq -n '[inputs]' <<< '1 2 3'   →  []
$ jq '.a' <<< '1 {"a":2}'         →  aborts on first error, prints nothing for {"a":2}
$ jq . missing.json ok.json       →  aborts
Oracle bench: jq 67.5% pass

After

$ jq -n '[inputs]' <<< '1 2 3'   →  [1,2,3]
$ jq '.a' <<< '1 {"a":2}'         →  jq: error (at <stdin>:1): Cannot index number with "a"
                                     2   (exit 5)
$ jq . missing.json ok.json       →  error for missing.json, contents of ok.json, exit 2
Oracle bench: jq 74.2% pass

Risk

Low to medium. The change is limited to jq input handling and error formatting. The size-limit error path is unchanged.

Checklist

  • Unit and integration tests (positive and negative cases), including differential checks against real jq
  • cargo clippy -D warnings, cargo fmt
  • Docs (jq.md) and knowledge log updated

https://claude.ai/code/session_01VscpEzxtqpCKx5eRMpywNj


Generated by Claude Code

-n leaves the stream to input/inputs, -s on empty input gives [], files are
read one by one (input_filename, jq's line counting), missing files are
skipped with exit 2, runtime errors are reported with their location and
processing continues, input fails with 'No more inputs', -e uses the last
output, values before a syntax error are processed.

Claude-Session: https://claude.ai/code/session_01VscpEzxtqpCKx5eRMpywNj
@cloudflare-workers-and-pages

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Preview URL Updated (UTC)
✅ Deployment successful!
View logs
bashkit 7f1eb18 Commit Preview URL

Branch Preview URL
Oct 07 2026, 08:02 PM

@chaliy
chaliy merged commit 51219ab into main Oct 7, 2026
47 checks passed
@chaliy
chaliy deleted the claude/project-thread-1mku65 branch October 7, 2026 20:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant