Registration returns HTTP 500 (panic: "Service \"alias\" does not exist or has not been built yet") when auto_join_rooms is non-empty #2012
Labels
No labels
Abandoned
Blocked
Bug
Changelog
Added
Changelog
Missing
Changelog
None
Cherry-picking
Database
Dependencies
Dependencies/Renovate
Difficulty
Easy
Difficulty
Hard
Difficulty
Medium
Documentation
Enhancement
Good first issue
Help wanted
Inherited
Matrix/Administration
Matrix/Appservices
Matrix/Auth
Matrix/Client
Matrix/Core
Matrix/E2EE
Matrix/Federation
Matrix/Hydra
Matrix/MSC
Matrix/Media
Matrix/T&S
Merge
Merge/Manual
Merge/Squash
Meta
Meta/CI
Meta/Packaging
Priority
Blocking
Priority
High
Priority
Low
Security
Status
Confirmed
Status
Duplicate
Status
Invalid
Status
Needs Investigation
Support
bob the builder
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
continuwuation/continuwuity#2012
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
On a server with a non-empty auto_join_rooms, POST /_matrix/client/v3/register panics and returns 500 M_UNKNOWN for every new registration. The account row is written before the panic, so the account exists and the user can log in afterwards — but the registration request fails, no device/access token is returned, and the user is never auto-joined to the configured rooms.
The trigger is the auto-join step in create_local_account, whose first action is to resolve the room via the alias service. The users-service's lazy Depalias::Service fails to resolve on this path and panics.
Affected versions
Worked prior to v26.6.0 (auto-join was functioning before upgrading).
Configuration to reproduce
[global]
allow_registration = true
auto_join_rooms = ["#lobby:example.com"] # any non-empty list
suspend_on_register = false
[global.oauth]
compatibility_mode = "disabled" # legacy registration path
Steps to reproduce
Expected
200 OK with user_id, access_token, device_id; the new user is auto-joined to #lobby:example.com
Actual
Client receives:
MatrixError: [500] M_UNKNOWN: Internal server error occurred
(POST https://matrix.example.com/_matrix/client/v3/register)
Server logs (worker thread panics):
ERROR conduwuit_core::error::log: Service "alias" does not exist or has not been built yet. in conduwuit_api::client::account::register::register
thread 'conduwuit:worker' panicked at src/service/service.rs:136:10:
Failure to reference service required by another service.: Service "alias" does not exist or has not been built yet.
ERROR conduwuit_router::request: 500 Internal Server Error, method: POST, uri: /_matrix/
The account is nonetheless created (it can be logged into afterwards); only the registration request fails and no auto-join occurs.
Root cause (analysis)
register_route → create_local_account writes the account first, then runs the auto-join loop:
for room in &self.services.config.auto_join_rooms {
let Ok(room_id) = self.services.alias.resolve(room).await else { … };
self.services.alias is a lazy Depalias::Service (src/service/users/mod.rs:59, wired at :111). On first deref it calls require() (src/service/service.rs:133-137), which looks the service up by name and gets None, so it panics.
Workaround
Set auto_join_rooms = [] and invite users to the room(s) by other means.
Environment