-
Notifications
You must be signed in to change notification settings - Fork 19
fix: use default power level when one isn't in state #206
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
WalkthroughIntroduces a null-safe fallback for missing power level events in resolveStateV2Plus by defaulting to a new PowerLevelEvent().toEventBase() when not found in partiallyResolvedState. Adds the corresponding import and removes an unused import. No other logic or public APIs are altered. Changes
Sequence Diagram(s)sequenceDiagram
autonumber
participant R as resolveStateV2Plus
participant S as partiallyResolvedState
participant P as PowerLevelEvent
R->>S: get("m.room.power_levels")
alt Event exists
S-->>R: powerLevelEventBase
note right of R: Use retrieved event base
else Missing
R->>P: new PowerLevelEvent()
P-->>R: toEventBase()
note right of R: Use default event base
end
R->>R: Continue state resolution with event base
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Poem
Pre-merge checks and finishing touches✅ Passed checks (3 passed)
✨ Finishing touches
🧪 Generate unit tests
Comment |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #206 +/- ##
=======================================
Coverage 81.01% 81.01%
=======================================
Files 63 63
Lines 4692 4692
=======================================
Hits 3801 3801
Misses 891 891 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (1)
packages/room/src/state_resolution/definitions/algorithm/v2.ts (1)
269-273: Good fallback; verify the synthetic PL event shape won’t break mainline ordering.Defaulting to a PL event avoids crashes when it’s missing, but please confirm:
- PowerLevelEvent().toEventBase() returns a PersistentEventBase with type 'm.room.power_levels' and state_key ''.
- It includes required fields used by mainlineOrdering (e.g., eventId, origin_server_ts) or that mainlineOrdering does not depend on them for the PL pivot.
- Passing a non-persisted/synthetic event won’t trigger wrappedStore lookups by eventId.
If any of the above aren’t guaranteed, consider guarding mainlineOrdering to treat a “synthetic PL” as a pure config carrier (no lookups), or inject a sentinel eventId to avoid accidental fetches.
Also suggest adding a brief comment here to document why a default PL is safe per the Matrix spec defaults.
Add a focused test to lock this in:
// pseudo-test it('resolves when no m.room.power_levels in partiallyResolvedState', async () => { // construct states with no PL event const result = await resolveStateV2Plus(statesWithoutPL, store); expect(result).toBeInstanceOf(Map); // optionally: assert deterministic ordering of a small conflicting set });
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
Disabled knowledge base sources:
- Jira integration is disabled by default for public repositories
You can enable these sources in your CodeRabbit configuration.
📒 Files selected for processing (1)
packages/room/src/state_resolution/definitions/algorithm/v2.ts(2 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
packages/room/src/state_resolution/definitions/algorithm/v2.ts (1)
packages/room/src/state_resolution/definitions/definitions.ts (1)
getStateMapKey(10-15)
🔇 Additional comments (1)
packages/room/src/state_resolution/definitions/algorithm/v2.ts (1)
62-62: Import looks correct and scoped to usage.Pathing aligns with existing manager imports. No issues.
https://rocketchat.atlassian.net/browse/FDR-140
Summary by CodeRabbit