Skip to content

Conversation

TrevisGordan
Copy link
Contributor

Problem

see: #16924
The [POST /_matrix/client/v3/rooms/{roomId}/-action-] endpoint currently returns an Internal Server Error when processing a payload containing a user_id from a different home server or an invalid (non-local) user ID with non existing room. This occurs due to an unhandled standard Exception in the get_local_current_membership_for_user_in_room function within roommember.py.

This PR addresses the issue by improving the error handling for non-local user IDs.

  1. Modified Exception Handling: Replace the standard Exception in get_local_current_membership_for_user_in_room with a SynapseError, providing a clear and specific error message to the API consumer.

    message = f"Provided user_id {user_id} is a non-local user"
    raise SynapseError(HTTPStatus.BAD_REQUEST, message, errcode=Codes.M_BAD_JSON)

Testing

  • Added unit tests to verify correct error handling for non-local user IDs.

Notes

Closes: #16924

Pull Request Checklist

  • Pull request is based on the develop branch
  • Pull request includes a changelog file. The entry should:
    • Be a short description of your change which makes sense to users. "Fixed a bug that prevented receiving messages from other servers." instead of "Moved X method from EventStore to EventWorkerStore.".
    • Use markdown where necessary, mostly for code blocks.
    • End with either a period (.) or an exclamation mark (!).
    • Start with a capital letter.
    • Feel free to credit yourself, by adding a sentence "Contributed by @github_username." or "Contributed by [Your Name]." to the end of the entry.
  • Code style is correct
    (run the linters)

@TrevisGordan TrevisGordan requested a review from a team as a code owner August 23, 2024 17:52
Copy link
Member

@anoadragon453 anoadragon453 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some minor wording changes, but otherwise LGTM. Thanks!

@anoadragon453 anoadragon453 enabled auto-merge (squash) August 29, 2024 14:08
@anoadragon453 anoadragon453 merged commit 594cd5f into element-hq:develop Aug 29, 2024
39 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Handling Non-Local user_id in Room Actions Causes Internal Server Error - validation
2 participants