Repository navigation
Make filter limit optional and harden filter and negentropy parsing - #142
Conversation
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 44 minutes. View limit detailsLimit details: You’ve used the included review currently available. Review configuration: ⚙️ Run configuration
📒 Files selected for processing (3)
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configuration
📒 Files selected for processing (3)
Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review. WalkthroughFilter limits now use optional unsigned values, and serialization preserves an explicitly set zero. Message parsing clamps out-of-range filter integers and maps negative relay ChangesFilter Limits and Parsing
Priority: ⬇️ Low Estimated code review effort: 3 (Moderate) | ~20 minutes Change: Bug fix Merge Risk: ⚪ Minimal · up to The change appears ready to merge: its intentional breaking API change is documented, no in-repository callers remain on the old signature, and no concrete user-facing failure is established. Architecture SummaryArchitecture risk: 🔵 Low · up to The change affects 2 systems. Changed systems: Architecture concerns Review detailsSystems and components
Before / after behavior
🚥 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. A rabbit checks the limit field, Comment |
NIP-01 now requires a relay to return no stored events for a filter with
"limit": 0, then sendEOSEand keep the subscription live.limit_valdefaulted to 0, solimit: 0was indistinguishable from no limit. It is now?u32, andFilter.limit()returns?u32(breaking).Untrusted input hardening:
@intCastfrom the JSONi64intoi32forlimitandkinds, so aREQwith"limit": 99999999999panicked in Debug and ReleaseSafe and was undefined behavior in ReleaseFast.limitnow saturates atu32max, a negativelimitis ignored, and a negative relayCOUNTparses as 0.kindsentries outsidei32or not integers are dropped. Anids,authorsorkindsarray that is non-empty but has no usable entry now yields an empty slice (matches nothing) instead of null (matches everything).reconcilecast the mode varint straight into the exhaustiveModeenum, so a mode byte of 3 or more panicked or was undefined behavior. A varint that decoded to zero length left the input unconsumed and looped forever. Both now returnParseError.Tests cover each case, including a negentropy test that crashes on the previous code.