Skip to content

Conversation

@debdutdeb
Copy link
Member

@debdutdeb debdutdeb commented Dec 15, 2025

Summary by CodeRabbit

Release Notes

  • Bug Fixes
    • Corrected room tombstone event structure to properly include the state key field, ensuring consistent and valid event formatting.

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Dec 15, 2025

Walkthrough

This pull request adds an explicit state_key: '' field to m.room.tombstone event payloads in the federation SDK and updates the corresponding schema to use PduNoContentEmptyStateKeyStateEventSchema instead of PduNoContentTimelineEventSchema, ensuring consistent tombstone event structure across the codebase.

Changes

Cohort / File(s) Summary
Tombstone Event Structure
packages/federation-sdk/src/services/room.service.ts
Adds state_key: '' to the m.room.tombstone event payload in RoomService.markRoomAsTombstone method.
Tombstone Event Schema
packages/room/src/types/v3-11.ts
Updates EventPduTypeRoomTombstone schema base from PduNoContentTimelineEventSchema to PduNoContentEmptyStateKeyStateEventSchema for proper state event field structure.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

  • Verify that the state_key: '' addition in the service layer aligns with the schema change
  • Confirm that the schema inheritance change correctly maps to Matrix spec requirements for tombstone events
  • Check for consistency with other "empty state key" event types using the same schema base

Possibly related PRs

Suggested reviewers

  • ggazzo
  • sampaiodiego

Poem

🐰 The tombstone now stands tall and true,
With state_key gleaming, brand spanking new,
Schema aligned from timeline to state,
Events are structured—forever their fate! ✨

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'fix: tombstone event classification' directly addresses the main change: reclassifying the EventPduTypeRoomTombstone schema from a timeline event to a state event with empty state key.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix-state-type

📜 Recent 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.

📥 Commits

Reviewing files that changed from the base of the PR and between ca2c498 and 8ff8cda.

📒 Files selected for processing (2)
  • packages/federation-sdk/src/services/room.service.ts (1 hunks)
  • packages/room/src/types/v3-11.ts (1 hunks)
🧰 Additional context used
🧠 Learnings (1)
📚 Learning: 2025-10-10T22:18:31.655Z
Learnt from: sampaiodiego
Repo: RocketChat/homeserver PR: 224
File: packages/federation-sdk/src/services/event-authorization.service.ts:261-268
Timestamp: 2025-10-10T22:18:31.655Z
Learning: In packages/federation-sdk/src/services/state.service.ts, the method `StateService.getLatestRoomState(roomId: string)` has return type `Promise<State>` and never returns undefined. If the state is not found, it throws an error with message "No state found for room ${roomId}" instead of returning undefined.

Applied to files:

  • packages/federation-sdk/src/services/room.service.ts
  • packages/room/src/types/v3-11.ts
🔇 Additional comments (2)
packages/room/src/types/v3-11.ts (1)

732-736: Switching tombstone to the empty-state-key state base is correct

Using PduNoContentEmptyStateKeyStateEventSchema here ensures m.room.tombstone PDUs are always treated as state events with state_key: '', consistent with how other empty-state-key state events are modeled and with the Matrix spec. This also matches the updated tombstone construction in the SDK.

packages/federation-sdk/src/services/room.service.ts (1)

1376-1393: Adding state_key: '' to tombstone events correctly matches the schema

Including state_key: '' in the m.room.tombstone payload makes this builder consistent with the new PduNoContentEmptyStateKeyStateEventSchema base and with other empty-state-key state events. This avoids validation/type mismatches and aligns with tombstone being a state event.


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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@codecov-commenter
Copy link

Codecov Report

❌ Patch coverage is 50.00000% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 53.15%. Comparing base (7346b3a) to head (8ff8cda).
⚠️ Report is 2 commits behind head on main.

Files with missing lines Patch % Lines
...ckages/federation-sdk/src/services/room.service.ts 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #319      +/-   ##
==========================================
- Coverage   53.37%   53.15%   -0.23%     
==========================================
  Files          96       96              
  Lines       12827    12797      -30     
==========================================
- Hits         6847     6802      -45     
- Misses       5980     5995      +15     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants