Support MSC4446: Move fully read markers backwards#59
Conversation
📝 WalkthroughSummary by CodeRabbitNew Features
WalkthroughThis change implements a new experimental feature ( Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes 🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
synapse/rest/client/read_marker.py (1)
78-88: Inconsistent validation with/receiptendpoint.In
receipts.py(lines 88-94),allow_backward=trueis explicitly rejected for non-FULLY_READreceipt types. Here, if a client sendscom.beeper.allow_backward: truewithout includingm.fully_readin the body, the parameter is silently ignored.Consider adding validation to reject the request when
allow_backwardis true but nom.fully_readkey is present, for API consistency:Suggested validation
if self.config.experimental.msc4446_enabled: allow_backward = body.get("com.beeper.allow_backward", False) if not isinstance(allow_backward, bool): raise SynapseError( 400, "com.beeper.allow_backward must be a boolean.", Codes.INVALID_PARAM, ) + if allow_backward and ReceiptTypes.FULLY_READ not in body: + raise SynapseError( + 400, + f"com.beeper.allow_backward is only valid when {ReceiptTypes.FULLY_READ} is present.", + Codes.INVALID_PARAM, + ) unrecognized_types -= {"com.beeper.allow_backward"} else: allow_backward = False🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@synapse/rest/client/read_marker.py` around lines 78 - 88, The current branch in read_marker.py accepts com.beeper.allow_backward=true and then silently ignores it if no m.fully_read is provided; mirror receipts.py behavior by validating this: after parsing allow_backward in the block guarded by self.config.experimental.msc4446_enabled, if allow_backward is True and the request body does not contain the "m.fully_read" key, raise a SynapseError(400, "com.beeper.allow_backward may only be true when m.fully_read is present.", Codes.INVALID_PARAM) so the invalid combination is rejected; update any related unrecognized_types handling (the existing unrecognized_types -= {"com.beeper.allow_backward"}) as needed.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@synapse/rest/client/read_marker.py`:
- Around line 78-88: The current branch in read_marker.py accepts
com.beeper.allow_backward=true and then silently ignores it if no m.fully_read
is provided; mirror receipts.py behavior by validating this: after parsing
allow_backward in the block guarded by self.config.experimental.msc4446_enabled,
if allow_backward is True and the request body does not contain the
"m.fully_read" key, raise a SynapseError(400, "com.beeper.allow_backward may
only be true when m.fully_read is present.", Codes.INVALID_PARAM) so the invalid
combination is rejected; update any related unrecognized_types handling (the
existing unrecognized_types -= {"com.beeper.allow_backward"}) as needed.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 988c8a8e-44c4-4383-98de-ae5c1c134fea
📒 Files selected for processing (5)
synapse/config/experimental.pysynapse/handlers/read_marker.pysynapse/rest/client/read_marker.pysynapse/rest/client/receipts.pysynapse/rest/client/versions.py
📜 Review details
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (4)
- GitHub Check: test-sytest
- GitHub Check: test-trial
- GitHub Check: test-complement
- GitHub Check: lint-types
🔇 Additional comments (7)
synapse/config/experimental.py (1)
603-605: LGTM!The experimental feature flag follows the established pattern for MSC configuration.
synapse/rest/client/versions.py (1)
183-184: LGTM!The unstable feature advertisement follows the existing pattern and uses the appropriate namespace.
synapse/rest/client/read_marker.py (1)
105-112: LGTM!The
allow_backwardparameter is correctly passed only forFULLY_READreceipts, matching the handler's expected behavior.synapse/rest/client/receipts.py (2)
79-96: LGTM!Thorough validation ensuring
allow_backwardis properly typed and restricted toFULLY_READreceipts only.
128-135: LGTM!The
allow_backwardparameter is correctly forwarded to the read marker handler forFULLY_READreceipts.synapse/handlers/read_marker.py (2)
42-49: LGTM!The new
allow_backwardparameter with a safe default ofFalsemaintains backward compatibility.
66-77: LGTM!The conditional logic correctly skips the ordering comparison when
allow_backward=True, allowing the marker to move backwards as specified by MSC4446.
|
I suppose this would be how we enable it after merging this: https://github.com/beeper/stack/pull/211 |
Upstream PR: element-hq/synapse#19663