Repository navigation
fix: do not fabricate a presence id from a missing protocol message id - #719
Conversation
|
No actionable comments were generated in the recent review. WalkthroughThe changes prevent synthesis of an inner presence-message ID when the protocol message has no ID. They also compare presence messages without IDs by timestamp and add tests for both behaviors. ChangesPresence message ID handling
Estimated code review effort: 2 (Simple) | ~10 minutes Change: Bug fix Suggested reviewers: Merge Risk:
|
There was a problem hiding this comment.
Copilot review overview
🔵 Needs a closer look
Add regression tests covering mixed IDs, both argument orders, and timestamp precedence.
Review effort: Lite
Findings: None
What changed in this PR
Fixes presence handling when protocol messages lack IDs by preserving missing IDs and using timestamp-based newness checks.
Changes:
- Prevents fabricated inner message IDs.
- Adds timestamp fallback for missing IDs.
- Adds regression tests.
| File | Summary |
|---|---|
test/unit/message_test.py |
Adds regression coverage for missing IDs. |
ably/types/message.py |
Prevents fabricated inner IDs. |
ably/realtime/presencemap.py |
Uses timestamps when IDs are missing; additional mixed-ID coverage is requested. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
f3bad52 to
1f0fd99
Compare
|
Rebased onto |
ttypic
left a comment
There was a problem hiding this comment.
LGTM, thanks for contribution! changed issue link from "fixes" to "refs", because pr does not fully fix the issue. Any other id that can't be parsed (for example one with a non-numeric serial) still makes parse_id() raise inside PresenceMap.put().
Summary
Refs #706.
When a
PRESENCEprotocol message carried noid,Message.update_inner_message_fieldsset each inner message id to the string"None:<index>". The RTP2b newness check then failed to parse that id and raisedValueError. The transport logged the exception and dropped the presence message.Changes
ably/types/message.py: set an inner message id from the protocol message only when the protocol message has an id.ably/realtime/presencemap.py:_is_newercompares by timestamp (RTP2b1) when either message has no id, instead of callingparse_id().test/unit/message_test.py: add tests for both changes.Testing
pytest test/unit test/ably/realtime/presencemap_test.py: 130 passed.ruff check ably test/unit: clean.The third point in the issue, what
is_synthesized()returns for a message without an id, is unchanged. Messages without an id now never reach the id-based comparison.Summary by CodeRabbit