mirror of
https://git.anonymousland.org/anonymousland/synapse.git
synced 2024-09-06 22:41:57 +00:00
Don't crash when one of the configuration files is empty (#7341)
If the admin adds a `.yaml` file that's either empty or doesn't parse into a dict to a config directory (e.g. `conf.d` for debs installs), stuff like https://github.com/matrix-org/synapse/issues/7322 would happen. This PR checks that the file is correctly parsed into a dict, or ignores it with a warning if it parses into any other type (including `None` for empty files). Fixes https://github.com/matrix-org/synapse/issues/7322
This commit is contained in:
parent
7bfe0902ce
commit
cc9eceb00d
1
changelog.d/7341.bugfix
Normal file
1
changelog.d/7341.bugfix
Normal file
@ -0,0 +1 @@
|
|||||||
|
Fix bad error handling that would cause Synapse to crash if it's provided with a YAML configuration file that's either empty or doesn't parse into a key-value map.
|
@ -657,6 +657,12 @@ def read_config_files(config_files):
|
|||||||
for config_file in config_files:
|
for config_file in config_files:
|
||||||
with open(config_file) as file_stream:
|
with open(config_file) as file_stream:
|
||||||
yaml_config = yaml.safe_load(file_stream)
|
yaml_config = yaml.safe_load(file_stream)
|
||||||
|
|
||||||
|
if not isinstance(yaml_config, dict):
|
||||||
|
err = "File %r is empty or doesn't parse into a key-value map. IGNORING."
|
||||||
|
print(err % (config_file,))
|
||||||
|
continue
|
||||||
|
|
||||||
specified_config.update(yaml_config)
|
specified_config.update(yaml_config)
|
||||||
|
|
||||||
if "server_name" not in specified_config:
|
if "server_name" not in specified_config:
|
||||||
|
Loading…
Reference in New Issue
Block a user