Skip to content

fix(jq): null-path assignment, array growth, join, scan groups, from_entries and tostream like jq - #2602

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

chaliy merged 2 commits 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

  • Assigning through null creates the containers, as in jq: null | .a.b = 1, .[2] = 1, +=, slice updates. An index past the end pads the array with null. Negative and too-large indexes and iterating a scalar now use jq's error texts.
  • join follows jq 1.7: null becomes an empty string, and numbers and booleans are stringified.
  • scan with capture groups returns the groups. Unmatched groups in match/capture give null strings with offset -1.
  • ltrimstr/rtrimstr match jq on non-string input.
  • from_entries accepts key/Key/name/Name and value/Value.
  • Added IN/1, IN/2, tostream, fromstream and truncate_stream.
  • DEL (\x7f) is escaped on output.
  • A non-string object key is an error.

Why

Adopting the Debian-oracle jq cases from pseudo-linus (bench scored against jq 1.7.1 goldens). These are common agent filter idioms that errored or gave wrong output.

Before / After

Filter Before After
null | .a.b = 1 Cannot iterate over null (null) {"a":{"b":1}}
[1] | .[3] = 2 index 3 out of bounds [1,null,null,2]
["a",1,null] | join("-") "a-1-null" "a-1-"
"a1b2" | [scan("([a-z])([0-9])")] ["a1","b2"] [["a","1"],["b","2"]]
[{name:"k",value:1}] | from_entries {"null":1} {"k":1}
{a:[1]} | [tostream] tostream/0 is not defined [[["a",0],1],[["a",0]],[["a"]]]

The Debian-oracle jq score went from 75.8% to 84.0% (lenient).

Risk

  • Low
  • The changes are confined to the jq builtin (vendored jaq-json value ops and the compat defs). Scripts that relied on the old wrong outputs will change.

Checklist

  • Tests added or updated (jq unit tests, 325 passing)
  • Backward compatibility considered (behavior now matches jq)

Generated by Claude Code

@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 f8b7f42 Commit Preview URL

Branch Preview URL
Oct 07 2026, 09:32 PM

@chaliy
chaliy merged commit 4941083 into main Oct 7, 2026
44 checks passed
@chaliy
chaliy deleted the claude/project-thread-1mku65 branch October 7, 2026 22:06
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