element-hq / element-hq/synapse
Syntax errors in `homeserver.yaml` lead to unclear errors
- Dominant language
- Python
- Stars
- 4.6k
- Forks
- 600
- Avg merge
- 5d 22h
- Merged PRs (30d)
- 51
Description
This issue has been migrated from [#8738](https://github.com/matrix-org/synapse/issues/8738).
---
**Description:**
Currently using the latest packages for ubuntu, having a malformed homeserver.yaml does not give a clear error message, instead causing a traceback, which exits 0, which then causes an automatic restart. This makes checking systemctl status in order to find out what went wrong very confusing. And then a check of journalctl gives something similar to the following
``` Traceback (most recent call last):
File "/usr/lib/python3.6/runpy.py", line 193, in _run_module_as_main
"__main__", mod_spec)
File "/usr/lib/python3.6/runpy.py", line 85, in _run_code
exec(code, run_globals)
File "/opt/venvs/matrix-synapse/lib/python3.6/site-packages/synapse/app/homeserver.py", line 512, in , but found %r" % token.id, token.start_mark)
yaml.parser.ParserError: while parsing a block mapping
in "/etc/matrix-synapse/homeserver.yaml", line 35, column 1
expected , but found ''
in "/etc/matrix-synapse/homeserver.yaml", line 727, column 3
matrix-synapse.service: Control process exited, code=exited status=1
matrix-synapse.service: Failed with result 'exit-code'.
Failed to start Synapse Matrix homeserver.
matrix-synapse.service: Service hold-off time over, scheduling restart.
matrix-synapse.service: Scheduled restart job, restart counter is at 1.
Stopped Synapse Matrix homeserver.
Starting Synapse Matrix homeserver...
Traceback (most recent call last):
File "/usr/lib/python3.6/runpy.py", line 193, in _run_module_as_main
"__main__", mod_spec)
File "/usr/lib/python3.6/runpy.py", line 85, in _run_code
exec(code, run_globals)
File "/opt/venvs/matrix-synapse/lib/python3.6/site-packages/synapse/app/homeserver.py", line 512, in , but found %r" % token.id, token.start_mark)
yaml.parser.ParserError: while parsing a block mapping
in "/etc/matrix-synapse/homeserver.yaml", line 35, column 1
expected , but found ''
in "/etc/matrix-synapse/homeserver.yaml", line 727, column 3```
A more clear error message I think would save people some headache.
Contributor guide
Research direction
Start in synapse/config/_base.py at read_config_files and follow how synapse/app/homeserver.py starts configuration loading with yaml.safe_load. Reproduce the malformed homeserver.yaml case described in the issue and inspect the existing startup tests, if present. Done means malformed YAML produces a clear actionable error and the service exits with an appropriate failure status instead of an unhelpful traceback or restart loop.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- backend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 30/100