Skip to content

fix: state the encodable range in Cbor.NumberTooLargeError - #675

Open
pucedoteth wants to merge 1 commit into
wevm:mainfrom
pucedoteth:fix/cbor-number-too-large-message
Open

pucedoteth wants to merge 1 commit into
wevm:mainfrom
pucedoteth:fix/cbor-number-too-large-message

Conversation

@pucedoteth

Copy link
Copy Markdown

Cbor.encode only encodes integers from -4294967296 to 4294967295 (the 32-bit forms; the decoder rejects 64-bit integers via Cbor.Unsupported64BitIntegerError). Values outside that range throw Cbor.NumberTooLargeError, but its message said:

Number exceeds maximum safe integer (9007199254740991): 4294967296

so a safe integer such as 2 ** 32, or a millisecond timestamp, was reported as exceeding Number.MAX_SAFE_INTEGER, a limit it is far below. The encoder's actual cap is already documented in Cbor.fuzz.ts ("caps positive numbers at 0xffffffff and negatives at -0x100000000"); only the message disagreed.

The message now states the real range:

Number is outside the encodable integer range (-4294967296 to 4294967295): 4294967296

The alternative, encoding safe integers with the 8-byte form, would also need Cbor.decode to accept 64-bit integers, which it currently rejects on purpose, so I kept this to the message.

  • Added a test asserting the message for 0x100000000 and -0x100000001. It fails without this PR and passes with it.
  • Added a patch changeset.
  • vp check passes, and all 178 Cbor tests pass.

`Cbor.encode` only encodes integers from -4294967296 to 4294967295 (the
decoder rejects 64-bit integers), but the error said the number exceeded
`Number.MAX_SAFE_INTEGER`. A safe integer such as 2**32 was reported as
exceeding a limit it is far below.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01L75E8Ap183JW1mDfv8arqR
@vercel

vercel Bot commented Nov 11, 2026

Copy link
Copy Markdown

@pucedoteth is attempting to deploy a commit to the Wevm Team on Vercel.

A member of the Team first needs to authorize it.

This branch has not been deployed

No deployments
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