Return 404 instead of 500 when client tries to join non-existent room #1579
No reviewers
Labels
No labels
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
Wont fix
old/ci/cd
old/rust
No milestone
No project
No assignees
2 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
continuwuation/continuwuity!1579
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "ezera/continuwuity:main"
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?
This pull request changes the error returned by the server when the user attempts to join a non-existent room (see #1443). Previously, the server returned error 500. Now, we return error 404, with a generic error message, which is closer to what Synapse does (as stated in #1443).
I considered returning
because I agree that it would make sense to prevent someone from enumerating which rooms exist. However, I settled on 404, because I thought it would make sense to mimic Synapse for the sake of client compatibility. Please let me know if you disagree.
I also defined a new
err!macro arm. I wasn't sure that was the best idea, but there didn't seem to be an existing arm that fit for returning this kind of error.I ran the tests locally, and everything passed, but I haven't added a test for this specific case.
Fixes: #1443
Pull request checklist:
mainbranch, and the branch is named something other thanmain.myself, if applicable. This includes ensuring code compiles.
@ -786,3 +786,3 @@if servers.is_empty() || servers.len() == 1 && services.globals.server_is_ours(&servers[0]) {return Err(error);return Err!(Request(Unknown("Unknown error"), NOT_FOUND));This masks Forbidden errors such as "not invited to room" and incorrectly returns 404 not found instead of 403 forbidden etc, which may (and will in future) hide important details from the end user. 404/M_UNKNOWN should only be returned if we genuinely don't know the room exists
Thanks! Does the new code match the behaviour you would expect?
Return 404 instead of 500 when client tries to join non-existent roomto WIP: Return 404 instead of 500 when client tries to join non-existent room2344e04107f740be422dWIP: Return 404 instead of 500 when client tries to join non-existent roomto Return 404 instead of 500 when client tries to join non-existent roomLooks good now, I just think the wording of the 404 could be improved
@ -786,2 +786,4 @@if servers.is_empty() || servers.len() == 1 && services.globals.server_is_ours(&servers[0]) {if !services.rooms.metadata.exists(room_id).await {return Err!(Request(Unknown("Unknown error"), NOT_FOUND));I think since we now know that we just don't have the room locally, an error message of
Room was not found locally and no servers were found to help us discover itmay be more descriptive thanUnknown error(thinking about all the people who may join our support room confused by "unknown error" when joining a room via ID with no vias)f740be422d0cc1e4685c