This repository has been archived by the owner on Apr 26, 2024. It is now read-only.
The Module API docs' DemoResource crashes #10837
Labels
S-Tolerable
Minor significance, cosmetic issues, low or no impact to users.
T-Defect
Bugs, crashes, hangs, security vulnerabilities, or other reported issues.
Description
The Module API docs include an example module, which is extremely helpful for a new module developer.
However, the DemoResource's
render_GET
function causes aTypeError
during JSON encoding and fails to return the intended response.Steps to reproduce
synapse/demo_module/__init__.py
homeserver.yaml
$ python3 -m synapse.app.homeserver --config-path homeserver.yaml
_synapse/client/demo/hello?name=world
in a browser or use cURL/wget/etcExpected to see the simple JSON response. Got "Processing Failed" instead.
Version information
If not matrix.org:
Version: 1.42.0
Install method: Git clone
Proposed Fix
Since the problem seems to be with the JSON encoder failing to handle bytes, we can simply decode the string before we put it into the JSON. Also, it seems that we need to encode the JSON string back to bytes before we return.
The text was updated successfully, but these errors were encountered: