fix: validate pagination params in memory tools - #2517
Open
ZayanKhan-12 wants to merge 1 commit into
Open
Conversation
|
Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). View this failed invocation of the CLA check for more information. For the most up to date status, view the checks section at the bottom of the pull request. |
ZayanKhan-12
force-pushed
the
fix/memory-pagination-schema
branch
from
August 8, 2026 21:46
6a8bc93 to
be935fc
Compare
Lightning00Blade
approved these changes
Aug 10, 2026
Lightning00Blade
left a comment
Collaborator
There was a problem hiding this comment.
LGTM, let's remove the test as we are testing as it test a library not our code.
| }); | ||
| }); | ||
|
|
||
| describe('pagination schemas', () => { |
Collaborator
There was a problem hiding this comment.
This test technically tests the zod, so we can remove it.
Lightning00Blade
enabled auto-merge
August 10, 2026 14:19
Lightning00Blade
disabled auto-merge
August 10, 2026 14:19
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The pagination params in
src/tools/memory.tswere declared as plainzod.number().optional(), while the equivalent params inconsole.tsandnetwork.tsuse stricter schemas (.int().positive()forpageSize,.int().min(0)forpageIdx).Because of the laxer schemas, invalid values reached
paginate()insrc/utils/pagination.ts:pageSize: 0producestotalPages: Infinity(Math.ceil(total / 0)) with an emptyitemsarraypageSizeslices nonsensical rangesThis PR aligns all five paginated memory tools (
get_heapsnapshot_details,get_heapsnapshot_class_nodes,get_heapsnapshot_retainers,get_heapsnapshot_edges,get_heapsnapshot_duplicate_strings) with the console/network schema pattern, including thedescribe()wording, so invalid values are rejected at the schema layer with a clear validation error instead of producing broken pagination output.docs/tool-reference.mdandsrc/bin/chrome-devtools-cli-options.tsare regenerated vianpm run gen.This inconsistency was noticed while writing pagination tests in #2510.
Changes
src/tools/memory.ts:pageSize→zod.number().int().positive().optional(),pageIdx→zod.number().int().min(0).optional()for all paginated memory toolstests/tools/memory.test.ts: newpagination schemastests asserting that0,-1, and non-integer values are rejected and valid values still parsedocs/tool-reference.md,src/bin/chrome-devtools-cli-options.ts: regeneratedTesting
npm run build— passesnpm run gen— regenerated docs/CLI options, no unexpected diffsnode scripts/test.js tests/tools/memory.test.ts— passes, including the new schema-rejection testsnpm run test:no-build— full suite passes (exit 0)npm run check-format— clean🤖 Generated with Claude Code