fix(alias): preserve room alias enumeration on delete #1567

Merged
nex merged 1 commit from 0xnim/continuwuity:fix/alias-enumeration-delete into main 2026-03-27 00:39:00 +00:00
Contributor

This pull request fixes a bug in room alias deletion where removing one alias could remove all aliasid_alias enumeration entries for that room.

remove_alias() previously deleted the full aliasid_alias prefix for the resolved room. That left the primary alias mappings (alias_roomid / alias_userid) partially intact, but caused local_aliases_for_room() and any callers that depend on alias enumeration to lose unrelated aliases for the same room.

This change updates alias removal to scan the room-scoped aliasid_alias entries, collect only the keys whose stored value matches the alias being deleted, and remove only those entries. It also removes all matching entries for that alias, which makes the cleanup resilient to duplicate stale index rows.

and made new tests:

  • deleting one alias while preserving another alias on the same room, (did not pass before)
  • deleting the last alias for a room, (did pass before)
  • deleting an alias when duplicate enumeration entries exist for that alias. (did not pass before)

This should make alias deletion behave consistently for alias listing, alias resolution, and flows that iterate room aliases such as moderation or room cleanup.

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 fixes a bug in room alias deletion where removing one alias could remove all `aliasid_alias` enumeration entries for that room. `remove_alias()` previously deleted the full `aliasid_alias` prefix for the resolved room. That left the primary alias mappings (`alias_roomid` / `alias_userid`) partially intact, but caused `local_aliases_for_room()` and any callers that depend on alias enumeration to lose unrelated aliases for the same room. This change updates alias removal to scan the room-scoped `aliasid_alias` entries, collect only the keys whose stored value matches the alias being deleted, and remove only those entries. It also removes all matching entries for that alias, which makes the cleanup resilient to duplicate stale index rows. and made new tests: - deleting one alias while preserving another alias on the same room, (did not pass before) - deleting the last alias for a room, (did pass before) - deleting an alias when duplicate enumeration entries exist for that alias. (did not pass before) This should make alias deletion behave consistently for alias listing, alias resolution, and flows that iterate room aliases such as moderation or room cleanup. **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. - [x] I have written a [news fragment][n1] for this PR, if applicable. [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 [n1]: https://towncrier.readthedocs.io/en/stable/tutorial.html#creating-news-fragments
@ -0,0 +117,4 @@
globals: Arc<globals::Service>,
}
impl TestEnv {
Owner

This seems to be at least the start of a testing environment. Yay! However, it should probably be higher up in the module hierarchy so it can be reused in more places

This seems to be at least the start of a testing environment. Yay! However, it should probably be higher up in the module hierarchy so it can be reused in more places
Author
Contributor

should i remove them from this pr?

should i remove them from this pr?
Owner

Nah, it can be moved later

Nah, it can be moved later
Jade approved these changes 2026-03-23 20:28:16 +00:00
0xnim force-pushed fix/alias-enumeration-delete from f842fd37e3
Some checks failed
Documentation / Build and Deploy Documentation (pull_request) Has been skipped
Checks / Prek / Pre-commit & Formatting (pull_request) Successful in 2m52s
Checks / Prek / Clippy and Cargo Tests (pull_request) Failing after 13m6s
to 3867472948
Some checks failed
Documentation / Build and Deploy Documentation (pull_request) Has been skipped
Checks / Prek / Pre-commit & Formatting (pull_request) Successful in 2m59s
Checks / Prek / Clippy and Cargo Tests (pull_request) Has been cancelled
2026-03-23 20:39:50 +00:00
Compare
0xnim force-pushed fix/alias-enumeration-delete from 3867472948
Some checks failed
Documentation / Build and Deploy Documentation (pull_request) Has been skipped
Checks / Prek / Pre-commit & Formatting (pull_request) Successful in 2m59s
Checks / Prek / Clippy and Cargo Tests (pull_request) Has been cancelled
to 27acc366be
Some checks failed
Documentation / Build and Deploy Documentation (pull_request) Has been skipped
Checks / Prek / Pre-commit & Formatting (pull_request) Successful in 3m0s
Checks / Prek / Clippy and Cargo Tests (pull_request) Failing after 7m54s
2026-03-23 20:43:03 +00:00
Compare
ginger approved these changes 2026-03-24 13:07:24 +00:00
Owner

This is good to merge once the Clippy failures are resolved

This is good to merge once the Clippy failures are resolved
0xnim force-pushed fix/alias-enumeration-delete from 27acc366be
Some checks failed
Documentation / Build and Deploy Documentation (pull_request) Has been skipped
Checks / Prek / Pre-commit & Formatting (pull_request) Successful in 3m0s
Checks / Prek / Clippy and Cargo Tests (pull_request) Failing after 7m54s
to 805f4e1a59
Some checks failed
Documentation / Build and Deploy Documentation (pull_request) Has been skipped
Checks / Prek / Pre-commit & Formatting (pull_request) Successful in 2m57s
Update flake hashes / update-flake-hashes (pull_request) Successful in 52s
Checks / Prek / Clippy and Cargo Tests (pull_request) Failing after 13m1s
2026-03-24 16:44:54 +00:00
Compare
0xnim force-pushed fix/alias-enumeration-delete from 805f4e1a59
Some checks failed
Documentation / Build and Deploy Documentation (pull_request) Has been skipped
Checks / Prek / Pre-commit & Formatting (pull_request) Successful in 2m57s
Update flake hashes / update-flake-hashes (pull_request) Successful in 52s
Checks / Prek / Clippy and Cargo Tests (pull_request) Failing after 13m1s
to 02bcdf442b
Some checks failed
Documentation / Build and Deploy Documentation (pull_request) Has been skipped
Checks / Prek / Pre-commit & Formatting (pull_request) Successful in 3m5s
Update flake hashes / update-flake-hashes (pull_request) Successful in 56s
Checks / Prek / Clippy and Cargo Tests (pull_request) Has been cancelled
2026-03-24 21:24:45 +00:00
Compare
nex approved these changes 2026-03-25 17:39:57 +00:00
nex left a comment
Owner

have a fourth approval

have a fourth approval
0xnim force-pushed fix/alias-enumeration-delete from 02bcdf442b
Some checks failed
Documentation / Build and Deploy Documentation (pull_request) Has been skipped
Checks / Prek / Pre-commit & Formatting (pull_request) Successful in 3m5s
Update flake hashes / update-flake-hashes (pull_request) Successful in 56s
Checks / Prek / Clippy and Cargo Tests (pull_request) Has been cancelled
to f17ae4a646
All checks were successful
Documentation / Build and Deploy Documentation (pull_request) Has been skipped
Check Changelog / Check for changelog (pull_request_target) Successful in 10s
Checks / Prek / Pre-commit & Formatting (pull_request) Successful in 2m58s
Update flake hashes / update-flake-hashes (pull_request) Successful in 1m48s
Checks / Prek / Clippy and Cargo Tests (pull_request) Successful in 17m32s
2026-03-26 19:04:46 +00:00
Compare
0xnim force-pushed fix/alias-enumeration-delete from f17ae4a646
All checks were successful
Documentation / Build and Deploy Documentation (pull_request) Has been skipped
Check Changelog / Check for changelog (pull_request_target) Successful in 10s
Checks / Prek / Pre-commit & Formatting (pull_request) Successful in 2m58s
Update flake hashes / update-flake-hashes (pull_request) Successful in 1m48s
Checks / Prek / Clippy and Cargo Tests (pull_request) Successful in 17m32s
to 8e7846c644
Some checks are pending
Documentation / Build and Deploy Documentation (pull_request) Has been skipped
Check Changelog / Check for changelog (pull_request_target) Successful in 10s
Checks / Prek / Pre-commit & Formatting (pull_request) Successful in 3m6s
Checks / Prek / Clippy and Cargo Tests (pull_request) Successful in 21m49s
Documentation / Build and Deploy Documentation (push) Waiting to run
Checks / Prek / Pre-commit & Formatting (push) Waiting to run
Checks / Prek / Clippy and Cargo Tests (push) Waiting to run
Release Docker Image / Build linux-amd64 (release) (push) Waiting to run
Release Docker Image / Build linux-arm64 (release) (push) Waiting to run
Release Docker Image / Create Multi-arch Release Manifest (push) Blocked by required conditions
Release Docker Image / Build linux-amd64 (max-perf) (push) Blocked by required conditions
Release Docker Image / Build linux-arm64 (max-perf) (push) Blocked by required conditions
Release Docker Image / Create Max-Perf Manifest (push) Blocked by required conditions
2026-03-26 19:23:25 +00:00
Compare
Author
Contributor

boom
done

boom done
Owner

shipit

shipit
nex merged commit 8e7846c644 into main 2026-03-27 00:39:00 +00:00
0xnim deleted branch fix/alias-enumeration-delete 2026-03-29 19:48:24 +00:00
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
5 participants
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!1567
No description provided.