Switch SUBSCRIBE_DROP to use start/end instead of start/count#997
Switch SUBSCRIBE_DROP to use start/end instead of start/count#997
Conversation
WalkthroughThe SubscribeDrop message was refactored in both TypeScript and Rust to replace 🚥 Pre-merge checks | ✅ 1 | ❌ 2❌ Failed checks (1 warning, 1 inconclusive)
✅ Passed checks (1 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ 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 |
There was a problem hiding this comment.
Actionable comments posted: 1
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
js/lite/src/lite/subscribe.ts (1)
265-296:⚠️ Potential issue | 🟡 MinorDocument
endsemantics and add a JSDoc comment to the public class.Same concern as the Rust struct:
endis undocumented as inclusive or exclusive, and the publicSubscribeDropclass lacks any JSDoc. As per coding guidelines, public APIs should be documented with clear docstrings or comments.📝 Suggested doc update
-/// Indicates that one or more groups have been dropped. -/// -/// Draft03 only. +/** + * Indicates that one or more groups in the range `[start, end]` (inclusive) have been dropped. + * + * Draft03 only. + */ export class SubscribeDrop { + /** First dropped group ID (inclusive). */ start: number; + /** Last dropped group ID (inclusive). */ end: number; error: number;🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@js/lite/src/lite/subscribe.ts` around lines 265 - 296, Add a JSDoc block to the public class SubscribeDrop that documents the class purpose and the meaning/semantics of each field (start, end, error), explicitly stating whether end is inclusive or exclusive, and any units or bounds; update the constructor and public methods (encode and static decode) signatures with short param/return JSDoc tags referencing SubscribeDrop, Writer and Reader so the API surface is clear (mention that encode delegates to Message.encode and decode uses SubscribeDrop.#decode). Ensure the comment appears immediately above the class declaration and uses consistent wording with other public types in the repo.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@rs/moq-lite/src/lite/subscribe.rs`:
- Around line 204-208: Document the inclusive/exclusive semantics of
SubscribeDrop::end (and clarify start) by adding a doc comment on the
SubscribeDrop struct or directly on the start and end fields that explicitly
states whether end is the index of the last dropped group (inclusive) or the
first non-dropped group (exclusive), and include an example or brief note about
how consumers should interpret them; update the comment for the error field if
needed to explain its relation to the range. Reference: SubscribeDrop struct and
its fields start, end, error.
---
Outside diff comments:
In `@js/lite/src/lite/subscribe.ts`:
- Around line 265-296: Add a JSDoc block to the public class SubscribeDrop that
documents the class purpose and the meaning/semantics of each field (start, end,
error), explicitly stating whether end is inclusive or exclusive, and any units
or bounds; update the constructor and public methods (encode and static decode)
signatures with short param/return JSDoc tags referencing SubscribeDrop, Writer
and Reader so the API surface is clear (mention that encode delegates to
Message.encode and decode uses SubscribeDrop.#decode). Ensure the comment
appears immediately above the class declaration and uses consistent wording with
other public types in the repo.
There was a problem hiding this comment.
🧹 Nitpick comments (1)
rs/moq-lite/src/lite/subscribe.rs (1)
220-232: Consider validatingstart <= endin the decode path.A malformed peer could send
end < start, which would decode cleanly into an inverted range. Any consumer iteratingstart..=end(a Rust inclusive range) over such a value would silently produce incorrect behavior (e.g., an empty iteration if using a checked range, or a wrap-around/panic if not).🛡️ Proposed defensive check
Ok(Self { start: u64::decode(r, version)?, end: u64::decode(r, version)?, error: u64::decode(r, version)?, })+ let start = u64::decode(r, version)?; + let end = u64::decode(r, version)?; + if end < start { + return Err(DecodeError::InvalidMessage(end)); + } Ok(Self { - start: u64::decode(r, version)?, - end: u64::decode(r, version)?, + start, + end, error: u64::decode(r, version)?, })🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@rs/moq-lite/src/lite/subscribe.rs` around lines 220 - 232, In decode_msg, after decoding start and end (the fields on the returned Self), validate that start <= end and return an appropriate DecodeError if the check fails; update the function handling in decode_msg (and any related version-specific branches if necessary) to perform this defensive check before constructing and returning Self so malformed inputs with end < start are rejected instead of producing inverted ranges at runtime.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@rs/moq-lite/src/lite/subscribe.rs`:
- Around line 220-232: In decode_msg, after decoding start and end (the fields
on the returned Self), validate that start <= end and return an appropriate
DecodeError if the check fails; update the function handling in decode_msg (and
any related version-specific branches if necessary) to perform this defensive
check before constructing and returning Self so malformed inputs with end <
start are rejected instead of producing inverted ranges at runtime.
No description provided.