-
Notifications
You must be signed in to change notification settings - Fork 228
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Handling Non-Local user_id
in Room Actions Causes Internal Server Error - validation
#16924
Comments
IMO here is Synapse not compliant to the Spec: https://spec.matrix.org/v1.10/client-server-api/#post_matrixclientv3roomsroomidinvite
The other endpoints do not have a defined error for this. |
I think Solution 1 is fine. However Note that I think this is only an issue for the following endpoints, which must be completed by a local user: ( For other actions, such as It would also be good to have a regression test which fails on the current codebase, but succeeds after the fix. |
Hey @anoadragon453, To reproduce this behavior and get a 500 error, a few conditions must be met:
The function elif effective_membership_state == Membership.LEAVE: (source) To call The question is whether it makes more sense to tackle the issue at its root, which involves the I implemented the said Synapse error, and created a Test. |
@anoadragon453 do you have thoughts on this? ;) |
Sorry for taking a while to respond to this. I think the diff you posted is sufficient, and suggest going ahead and opening a PR. In the test, I would have a one check for the a non-local user ID and another for the invalid room ID, instead of including both in a single request. I'd also double-check that the Thanks! |
Description
I've identified an issue with the
[POST /_matrix/client/v3/rooms/{roomId}/-action-]
endpoint, where submitting a payload containing auser_id
from a different home server or an invalid (non-local) user ID results in an Internal Server Error.The root cause of this issue lies within
roommember.py
in the functionget_local_current_membership_for_user_in_room
, which raises an unhandled standard Exception when encountering a non-local user.Current exception raising:
(Source: synapse / get_local_current_membership_for_user_in_room)
To resolve this issue, I suggest two potential approaches:
Modify the Existing Exception Handling: Replace the standard Exception within
get_local_current_membership_for_user_in_room
with aSynapseError
, providing a clear and specific error message to the API consumer. For instance:Handle the Exception at the Caller Function: Alternatively, the exception could be caught and handled appropriately within the functions that call
get_local_current_membership_for_user_in_room
, ensuring that aSynapseError
is raised there instead.This should improve error handling and user feedback when encountering non-local
user_id
s in room action requests, and better input validation preventing the generic Internal Server Error.Steps to reproduce
Homeserver
local
Synapse Version
1.94.0
Installation Method
Docker (matrixdotorg/synapse)
Database
PostgreSQL
Workers
Multiple workers
Platform
K8t
Configuration
No response
Relevant log output
Anything else that would be useful to know?
No response
The text was updated successfully, but these errors were encountered: