Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

Internal server error when using List Room API with no filtering #8188

Closed
anthr76 opened this issue Aug 27, 2020 · 5 comments
Closed

Internal server error when using List Room API with no filtering #8188

anthr76 opened this issue Aug 27, 2020 · 5 comments

Comments

@anthr76
Copy link

anthr76 commented Aug 27, 2020

Description

When requesting all rooms in your home server via admin API the following response is sent.

{
    "errcode": "M_UNKNOWN",
    "error": "Internal server error"
}

Steps to reproduce

  • Possibly federate rooms with emojis in room names
  • Curl /_synapse/admin/v1/rooms

This seems like it's an issue having emojis in the room names. When using a search term to narrow down the results the issue doesn't show up.

A traceback in synpase logs show:

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.7/site-packages/synapse/http/server.py", line 233, in _async_render_wrapper
    self._send_response(request, code, response)
  File "/usr/local/lib/python3.7/site-packages/synapse/http/server.py", line 295, in _send_response
    canonical_json=self.canonical_json,
  File "/usr/local/lib/python3.7/site-packages/synapse/http/server.py", line 536, in respond_with_json
    json_bytes = encode_pretty_printed_json(json_object) + b"\n"
  File "/usr/local/lib/python3.7/site-packages/canonicaljson.py", line 96, in encode_pretty_printed_json
    return _pretty_encoder.encode(json_object).encode("ascii")
UnicodeEncodeError: 'ascii' codec can't encode characters in position 10427-10428: ordinal not in range(1
28)

Some rooms not in my server but are federated by my server have emojis in the name. Which show up in the logs:

...'name': '🔊 Audio Corner', 'canonical_alias': '#audiocorner:jupiterbroadcasting.com', 'joined_members': 39, 'joined_local_members': 1, 'version': '5', 'creator': '', 'encryption': None, 'federatable': True, 'public': ...

Version information

  • Homeserver:

If not matrix.org:
matrix.rabbito.tech

  • Version:
{
    "python_version": "3.7.8",
    "server_version": "1.19.0"
}

  • Install method:

matrixdotorg docker container

  • Platform:

Containerized on Ubuntu 20.04 LTS

@clokep
Copy link
Contributor

clokep commented Aug 27, 2020

This sounds like the same as matrix-org/python-canonicaljson#33 -- a workaround is to specify a user-agent which isn't curl.

@anthr76
Copy link
Author

anthr76 commented Aug 27, 2020

This workaround succeeded !

@clokep
Copy link
Contributor

clokep commented Aug 27, 2020

Glad that worked! We'll need to release a new version of canonicaljson at some point with the fix in it. 👍

@clokep
Copy link
Contributor

clokep commented Sep 3, 2020

FYI we released an update for python-canonicaljson which should fix this. You can install 1.4.0 and it should work fine!

@richvdh
Copy link
Member

richvdh commented Sep 12, 2020

see also #8262 which adds a dependency on canonicaljson 1.4.0, so people upgrading to synapse 1.21.0 will automatically get this fix.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants