fix(google): bound tool schema expansion - #1355
Conversation
|
✅ Deterministic PR hygiene checks passed. |
📝 WalkthroughWalkthroughThe Google tool-schema sanitizer now enforces a 1,024-node traversal budget, prevents recursive ChangesGoogle schema sanitization
Estimated code review effort: 3 (Moderate) | ~20 minutes Possibly related PRs
Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
✅ READY
Review readiness checklist
✅ 4/4 boxes ticked. This pull request has been marked Ready for Review. |
|
@coderabbitai review |
✅ Action performedReview finished.
|
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@src/adapters/google-tool-schema.ts`:
- Around line 141-150: Bound property-key enumeration in the schema sanitization
function before the `for...in` loop over `value`: obtain only up to the allowed
`state.remainingNodes` keys, and return or stop without materializing the full
key list when the limit is exceeded. Apply the same bound before creating
`properties` entries or calling `sanitizeSchema`, while preserving own-property
filtering and budget-exhaustion behavior.
🪄 Autofix
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: ASSERTIVE
Plan: Pro Plus
Run ID: 7e572b57-b94e-41a6-83df-7720c2c52ead
📒 Files selected for processing (2)
src/adapters/google-tool-schema.tstests/google-tool-schema.test.ts
ad7ed6b to
408c825
Compare
|
|
Wibias
left a comment
There was a problem hiding this comment.
Thanks for the focused hardening here. The bounded schema-node budget, cycle-aware $ref handling, supported-key-only merge path, and regression coverage make this a strong fix for the expansion/DoS edge cases without widening scope. Exact-head Cross-platform CI and React Doctor are green. Merged — thank you!
Summary
$refexpansion to 1,024 attempted schema nodes.anyOf, anditemstraversal as soon as the budget is exhausted while retaining a valid, safely widened schema prefix.$reftargets, avoiding repeated copies of unrelated annotations.requirednames aligned with the properties that survive bounded sanitization.The previous depth and dereference limits stopped simple recursion but did not bound acyclic branching definitions. A compact shared
$defsgraph could therefore expand into a large amount of local CPU and memory work before a Google-family request was serialized.Verification
bun test tests/google-tool-schema.test.ts— 24 passedbun test tests/google-wire-compiler.test.ts— 4 passedbun run typecheckbun run privacy:scangit diff --checkbun run testwas attempted once. Unrelated Windows identity/catalog/history tests failed, then Bun 1.3.14 panicked after 1,242 seconds at 1.72 GB peak RSS; exact-head GitHub CI remains required.Checklist
Review readiness checklist
This PR stays in draft until every box below is ticked. Tick all four boxes once the requirements are met:
All CI tests are green on my local testing.
I pushed my PR to the latest dev commit.
I resolved all correct Codex and CodeRabbit findings.
My PR is ready for review.
Summary by CodeRabbit
Bug Fixes
Tests