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

Commit a64c299

Browse files
Pass a dict, instead of None, to modules if a None config is specified in the homeserver config (#9229)
If a Synapse module's config block were empty in YAML, thus being translated to a `Nonetype` in Python, then some modules could fail as that None ends up getting passed to their `parse_config` method. Modules are expected to accept a `dict` instead. This PR ensures that if the user does end up specifying an empty config block (such as what [the default oidc config in the sample config](https://github.com/matrix-org/synapse/blob/5310808d3bebd17275355ecd474bc013e8c7462d/docs/sample_config.yaml#L1816-L1845) states) then `None` is not passed to the module. An empty dict is passed instead. This code assumes that no existing modules are relying on receiving a `None` config block, but I'd really hope that they aren't.
1 parent 1baab20 commit a64c299

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

changelog.d/9229.bugfix

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Fix a bug where `None` was passed to Synapse modules instead of an empty dictionary if an empty module `config` block was provided in the homeserver config.

synapse/util/module_loader.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,8 @@ def load_module(provider: dict, config_path: Iterable[str]) -> Tuple[Type, Any]:
4949
module = importlib.import_module(module)
5050
provider_class = getattr(module, clz)
5151

52-
module_config = provider.get("config")
52+
# Load the module config. If None, pass an empty dictionary instead
53+
module_config = provider.get("config") or {}
5354
try:
5455
provider_config = provider_class.parse_config(module_config)
5556
except jsonschema.ValidationError as e:

0 commit comments

Comments
 (0)