fix: Include rooms with no new events in full_state syncs #2391

Open
mspnr wants to merge 2 commits from mspnr/continuwuity:fix/sync-full-state-empty-rooms into main
First-time contributor

This pull request makes /sync with full_state=true return every joined room even when nothing happened in it since the since token.

Before, build_state_events returned early for an empty timeline without looking at full_state. A quiet room therefore produced no state and no timeline, and was dropped from rooms.join. The spec says full_state returns the state of all rooms the user is a member of, even if since is set. Clients that persist their sync token but keep the room list in memory (matrix-nio, and through it Home Assistant's matrix_extended) get no rooms after a restart and conclude they are in none.

The change skips that early return when full_state is set. build_state_initial already handles an empty timeline and returns the current room state. Syncs without full_state are unchanged.

Testing

The change is 4 lines and has no Rust unit test; I checked the behaviour end to end against a throwaway server built from this branch (rebased on main at 2f93711a0), with the same requests run against the official 26.9.1 image as baseline:

  • full_state=true&since=<next_batch> with nothing new: official 26.9.1 returns an empty rooms.join; this branch returns both rooms with their full state and an empty timeline.
  • since=<next_batch> without full_state still returns nothing, and after one new event only the changed room carries a timeline.
  • matrix-nio 0.26.0 restart simulation (stored sync token, empty in-memory room list): fails on 26.8.1 and 26.9.1, passes with this branch.
  • Live instance with the Home Assistant integration: reloading with the saved token on a quiet token loads correctly with this change.

Checks run on this branch in a clean checkout (Rust 1.99.1 container): cargo +nightly fmt --all -- --check, cargo clippy --workspace --features full --locked --no-deps --profile test -- -D warnings, cargo test --workspace --features full --locked --profile test --all-targets --no-fail-fast, prek run --all-files --hook-stage manual and the committed commit-message hook all pass. Complement was not run.

Fixes: #2390

Pull request checklist:

  • This pull request targets the main branch, and the branch is named something other than main.
  • I have written an appropriate pull request title and my description is clear.
  • I understand I am responsible for the contents of this pull request.
  • I have followed the contributing guidelines:
This pull request makes `/sync` with `full_state=true` return every joined room even when nothing happened in it since the `since` token. Before, `build_state_events` returned early for an empty timeline without looking at `full_state`. A quiet room therefore produced no state and no timeline, and was dropped from `rooms.join`. The spec says `full_state` returns the state of all rooms the user is a member of, even if `since` is set. Clients that persist their sync token but keep the room list in memory (matrix-nio, and through it Home Assistant's `matrix_extended`) get no rooms after a restart and conclude they are in none. The change skips that early return when `full_state` is set. `build_state_initial` already handles an empty timeline and returns the current room state. Syncs without `full_state` are unchanged. **Testing** The change is 4 lines and has no Rust unit test; I checked the behaviour end to end against a throwaway server built from this branch (rebased on `main` at 2f93711a0), with the same requests run against the official 26.9.1 image as baseline: - `full_state=true&since=<next_batch>` with nothing new: official 26.9.1 returns an empty `rooms.join`; this branch returns both rooms with their full state and an empty timeline. - `since=<next_batch>` without `full_state` still returns nothing, and after one new event only the changed room carries a timeline. - matrix-nio 0.26.0 restart simulation (stored sync token, empty in-memory room list): fails on 26.8.1 and 26.9.1, passes with this branch. - Live instance with the Home Assistant integration: reloading with the saved token on a quiet token loads correctly with this change. Checks run on this branch in a clean checkout (Rust 1.99.1 container): `cargo +nightly fmt --all -- --check`, `cargo clippy --workspace --features full --locked --no-deps --profile test -- -D warnings`, `cargo test --workspace --features full --locked --profile test --all-targets --no-fail-fast`, `prek run --all-files --hook-stage manual` and the `committed` commit-message hook all pass. Complement was not run. Fixes: #2390 **Pull request checklist:** - [x] This pull request targets the `main` branch, and the branch is named something other than `main`. - [x] I have written an appropriate pull request title and my description is clear. - [x] I understand I am responsible for the contents of this pull request. - I have followed the [contributing guidelines][c1]: - [x] My contribution follows the [code style][c2], if applicable. - [x] I ran [pre-commit checks][c1pc] before opening/drafting this pull request. - [x] I have [tested my contribution][c1t] (or proof-read it for documentation-only changes) myself, if applicable. This includes ensuring code compiles. - [x] My commit messages follow the [commit message format][c1cm] and are descriptive. [c1]: https://forgejo.ellis.link/continuwuation/continuwuity/src/branch/main/CONTRIBUTING.md [c2]: https://forgejo.ellis.link/continuwuation/continuwuity/src/branch/main/docs/development/code_style.mdx [c1pc]: https://forgejo.ellis.link/continuwuation/continuwuity/src/branch/main/CONTRIBUTING.md#pre-commit-checks [c1t]: https://forgejo.ellis.link/continuwuation/continuwuity/src/branch/main/CONTRIBUTING.md#running-tests-locally [c1cm]: https://forgejo.ellis.link/continuwuation/continuwuity/src/branch/main/CONTRIBUTING.md#commit-messages
fix: Include rooms with no new events in full_state syncs
Some checks failed
Auto Labeler / Apply labels based on changed files (pull_request_target) Successful in 5s
Checks / Changelog / Check changelog is added (pull_request_target) Failing after 8s
Documentation / Build and Deploy Documentation (pull_request) Has been cancelled
Checks / Prek / Pre-commit & Formatting (pull_request) Has been cancelled
Checks / Prek / Check changed files (pull_request) Has been cancelled
Checks / Prek / Clippy and Cargo Tests (pull_request) Has been cancelled
f1e7ee3f9c
build_state_events returned early for an empty timeline without looking at
full_state, so a sync with `since` and `full_state=true` produced an empty
JoinedRoom for every quiet room, and those rooms were then dropped from
rooms.join. The spec says full_state returns the full state of all joined
rooms even when `since` is set. Skip the early return when full_state is set
so build_state_initial runs.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
chore: Add news fragment for the full_state sync fix
Some checks are pending
Documentation / Build and Deploy Documentation (pull_request) Blocked by required conditions
Checks / Prek / Pre-commit & Formatting (pull_request) Blocked by required conditions
Checks / Prek / Check changed files (pull_request) Blocked by required conditions
Checks / Prek / Clippy and Cargo Tests (pull_request) Blocked by required conditions
Checks / Changelog / Check changelog is added (pull_request_target) Successful in 7s
213ea10b17
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Some checks are pending
Documentation / Build and Deploy Documentation (pull_request) Blocked by required conditions
Checks / Prek / Pre-commit & Formatting (pull_request) Blocked by required conditions
Required
Details
Checks / Prek / Check changed files (pull_request) Blocked by required conditions
Required
Details
Checks / Prek / Clippy and Cargo Tests (pull_request) Blocked by required conditions
Required
Details
Checks / Changelog / Check changelog is added (pull_request_target) Successful in 7s
Required
Details
Some required checks are missing.
Some workflows are waiting to be reviewed.
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u fix/sync-full-state-empty-rooms:mspnr-fix/sync-full-state-empty-rooms
git switch mspnr-fix/sync-full-state-empty-rooms
Sign in to join this conversation.
No reviewers
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
continuwuation/continuwuity!2391
No description provided.