fix(protocol): size check before JSON parse in receiveEnvelope (#49)#65
Conversation
Reorder receiveEnvelope() to match SPEC §4.3 step 1: reject wire > 64 KiB before parseOuterVersion (JSON.parse). Oversized v:2 wire now returns envelope_too_large instead of unsupported_version, aligning the protocol host receiver with relay (M2.6). Closes #49
|
Warning Review limit reached
Next review available in: 52 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthrough
ChangesEnvelope validation ordering
Estimated code review effort: 2 (Simple) | ~10 minutes 🚥 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 |
|
|
||
| describe("receiveEnvelope steps 0–6 (§4.3)", () => { | ||
| it("step 0: unknown wire version → unsupported_version, dispatch not called", async () => { | ||
| describe("receiveEnvelope steps 1–6 (§4.3)", () => { |
There was a problem hiding this comment.
[nit] The describe block was renamed to steps 1–6 (§4.3) to match the §4.3 numbering, but a later case in the same block still says valid wire passing steps 0–6 continues to step 7+ (line 307). After this PR there is no “step 0” in either the implementation comments or the suite naming, so the leftover “0” is inconsistent and can confuse anyone mapping tests to SPEC steps.
Suggestion: Rename that case to valid wire passing steps 1–6 continues to step 7+ (or similar) in a follow-up or this PR if you touch the file again.
Rename leftover "steps 0–6" case label to match §4.3 numbering after issue #49 reorder (no step 0 in impl or suite).
Summary
receiveEnvelope()so SPEC §4.3 step 1 (64 KiB wire size check) runs beforeparseOuterVersion()/JSON.parsev: 2now returnsenvelope_too_largeinstead ofunsupported_version, matching relay inbox behavior (M2.6)v:2case; relabel §4.1 wire-version test for clarityCloses #49
Type of change
Test plan
pnpm --filter @agentpair/protocol test— 390 tests passedv:2wire →envelope_too_large(notunsupported_version)v:2wire →unsupported_versionstill passesenvelope_too_large(v:1 generative) unchanged and passingPre-flight checklist
envelope_too_largestays v:1 only)packages/relay/src/routes/inbox.tsSummary by CodeRabbit