Skip to content

feat(jq): halt/debug inside the command, -a/--raw-output0/--seq/--stream, $__loc__, ?// and date/base64 fixes - #2606

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

chaliy merged 5 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

  • halt and halt_error end the jq command with their exit code and skip any remaining input, as in jq. They used to fail with "halt is disabled in the bashkit sandbox". They stop only the jq command, never the shell or the host: the run loop never unwraps a halt.
  • stderr and debug write to jq's stderr. Messages are buffered per command and capped at 1 MiB (TM-INF-023 updated).
  • New flags:
    • -a / --ascii-output escapes non-ASCII as \uXXXX.
    • --raw-output0 is like -r with a NUL after each output; a string containing NUL is an error, as in jq.
    • --seq writes RS (0x1e) before each output and treats RS in input as a value separator.
    • --stream feeds path events, the same ones tostream produces.
  • $__loc__ gives {"file":"<top-level>","line":N}.
  • Destructuring alternatives . as P1 ?// P2 | body try each pattern in turn. Every variable named in any pattern is bound, null if its pattern didn't set it, and an error moves on to the next pattern.
  • Builtin fixes:
    • implode substitutes U+FFFD for invalid code points.
    • strptime uses jq's mismatch error text.
    • fromdateiso8601 and fromdate follow jq.
    • @base64d accepts missing padding and uses jq's error texts.

Why

These come from the Debian-oracle jq cases in pseudo-linus, which are recorded against jq 1.7.1. halt_error and --stream show up in real agent scripts, and before this they either errored or were rejected as unknown options.

Before / After

$ jq -n '1, (2|halt), 3'; echo "exit=$?"
before: 1 / jq: error (at <unknown>): halt is disabled in the bashkit sandbox / exit=5
after:  1 / exit=0

$ jq -n '"bye" | halt_error(1)'; echo "exit=$?"
before: halt is disabled in the bashkit sandbox / exit=5
after:  bye (on stderr) / exit=1

$ echo '[1]' | jq -c 'debug | .[0]'
before: 1
after:  1, plus ["DEBUG:",[1]] on stderr

$ jq -na '"é"'
before: "é"
after:  "é"

$ echo '{"a":[1]}' | jq -c --stream .
before: jq: Unknown option --stream
after:  [["a",0],1] / [["a",0]] / [["a"]]

$ jq -nc '$__loc__'
before: jq: error: $__loc__ is not defined
after:  {"file":"<top-level>","line":1}

$ jq -nc '[[1,2]] | .[] as [$a] ?// $a | [$a]'
before: jq: error: expected |
after:  [1]

With #2602, the Debian-oracle jq score goes from 84.0% to 88.7% (lenient).

Risk

  • Medium.
  • ?// and $__loc__ are implemented as source rewrites before compiling, aware of strings and comments, with at most 16 rewrites per filter. An unusual filter could be rewritten wrongly. The tests cover nesting, strings, comments and the cases where every pattern errors.
  • halt is a new path out of the run loop; tests check that it never ends the host.

Checklist

  • Tests added or updated (jq unit tests now 341, including halt/debug containment and the message cap)
  • Backward compatibility considered (only error-to-jq-behavior changes and new flags)

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 e822127 Commit Preview URL

Branch Preview URL
Oct 07 2026, 10:13 PM

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