Skip to content

fix: reject negative token limits and offsets - #254

Closed
HereForTheTechNFT wants to merge 2 commits into
wevm:mainfrom
HereForTheTechNFT:fix/negative-token-window
Closed

HereForTheTechNFT wants to merge 2 commits into
wevm:mainfrom
HereForTheTechNFT:fix/negative-token-window

Conversation

@HereForTheTechNFT

Copy link
Copy Markdown
Contributor

Closes #247

--token-limit and --token-offset only checked that the value was a finite number, so -5 or -3 passed. The command then ran, sliceByTokens took its window from the end of the output, and the footer printed a negative token range.

Changes:

  • Both flags now reject a negative value with the same ParseError as a non-numeric one (Invalid value for --token-limit: "-3"), so the command doesn't run and the exit code is 1. Zero stays valid.
  • Test for both flags: the error, the exit code, and that run is not called.
  • Changeset (patch).

pnpm vitest run passes, except bun-compile.test.ts and internal/binaryBuild.test.ts, which fail the same way on main in my environment (no Bun binary). pnpm check:types passes.

jxom commented Nov 24, 2026

Copy link
Copy Markdown
Member

Thanks for this, @HereForTheTechNFT! We've folded it into #319, which combines it with #296 (same token window code), ports the check to the Rust, Python, and Zig ports, and adds differential cases. You're credited as co-author there. Closing in favor of #319.

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.

fix(cli): negative token limits and offsets produce invalid output windows

2 participants