Repository navigation
fix(abi): limit decoded bytes and string size - #5483
Conversation
🦋 Changeset detectedLatest commit: 995944e The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: e777b3db6e
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| AbiDecodingSizeLimitExceededError & { | ||
| name: 'AbiDecodingSizeLimitExceededError' | ||
| } | ||
| export class AbiDecodingSizeLimitExceededError extends BaseError { |
There was a problem hiding this comment.
Export the new decoding error from the package entrypoint
When consumers need to handle the newly introduced size-limit failure, they cannot import AbiDecodingSizeLimitExceededError from viem to use instanceof or BaseError.walk. Repository-wide search shows the class is only exported from this internal module, while src/index.ts explicitly re-exports the other ABI errors and src/package.json does not expose an errors subpath. Re-export the class and its error type from src/index.ts so this new public failure can be handled consistently with existing decoding errors.
AGENTS.md reference: AGENTS.md:L92-L92
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Exported AbiDecodingSizeLimitExceededError and its type from viem and listed it in the errors glossary in e99e268.
|
Published pnpm add viem@pr-5483
pnpm add [email protected] |
decodeAbiParameters now limits the total size of decoded bytes and string values to 32 times the input size and throws AbiDecodingSizeLimitExceededError beyond it. Amp-Thread-ID: https://ampcode.com/threads/T-01a1c870-2498-70a3-8bfc-f9b921b52e75 Co-authored-by: jxom <[email protected]>
8a95bc0 to
90adea7
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 90adea70e7
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| export class AbiDecodingSizeLimitExceededError extends BaseError { | ||
| constructor({ limit }: { limit: number }) { |
There was a problem hiding this comment.
Keep the new decoding error in its owning module
The new error is specific to decodeAbiParameters, but its implementation is added to the shared error module. AGENTS.md explicitly requires module-specific failure classes to live near the bottom of the module that throws them. Move this class and its associated type into decodeAbiParameters.ts and update the entrypoint re-exports accordingly.
AGENTS.md reference: AGENTS.md:L29-L31
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Moved AbiDecodingSizeLimitExceededError and its type to the bottom of decodeAbiParameters.ts and re-exported them from viem alongside decodeAbiParameters in 995944e.
| AbiDecodingSizeLimitExceededError, | ||
| type AbiDecodingSizeLimitExceededErrorType, |
There was a problem hiding this comment.
Document the newly exported size-limit error
The new class and error type are now exported, but neither has TSDoc explaining the failure condition, and the entrypoint additions contain no documentation block. The glossary addition only lists the name, leaving consumers without API documentation for when the new exception is raised. Add the required TSDoc describing the cumulative decoded-size limit; AGENTS.md explicitly requires a TSDoc block when adding a public export.
AGENTS.md reference: AGENTS.md:L92-L92
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Added TSDoc to the class and its type describing when it is thrown (decoded bytes and string values exceeding 32 times the input size) in 995944e.
| import { getAddress } from '../address/getAddress.js' | ||
| import { size } from '../data/size.js' | ||
| import { hexToBytes } from '../encoding/toBytes.js' | ||
| import { numberToHex, stringToHex } from '../encoding/toHex.js' |
There was a problem hiding this comment.
Import the new public test helpers through the package entrypoint
The new tests import numberToHex and stringToHex directly from their implementation module even though both are public exports of viem. This bypasses the package surface and violates the explicit test-import convention in AGENTS.md. Import these helpers from 'viem' rather than adding new relative imports for public APIs.
AGENTS.md reference: AGENTS.md:L188-L192
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
The new tests now import numberToHex, size and stringToHex from viem in 995944e.
decodeAbiParametersnow limits the total size of decodedbytesandstringvalues to 32 times the input size, and throwsAbiDecodingSizeLimitExceededErrorbeyond it. Ordinary inputs, including offsets that share a tail, decode as before.