summary refs log tree commit diff
path: root/synapse
diff options
context:
space:
mode:
authorWill Hunt <will@half-shot.uk>2023-04-12 12:28:46 +0100
committerGitHub <noreply@github.com>2023-04-12 11:28:46 +0000
commit253e86a72e0c8e4e014b4b08fa587afe1de4db22 (patch)
tree11fbd52800395b4df6e71c315c98f1150f29aead /synapse
parentMerge branch 'master' into develop (diff)
downloadsynapse-253e86a72e0c8e4e014b4b08fa587afe1de4db22.tar.xz
Throw if the appservice config list is the wrong type (#15425)
* raise a ConfigError on an invalid app_service_config_files

* changelog

* Move config check to read_config

* Add test

* Ensure list also contains strings
Diffstat (limited to 'synapse')
-rw-r--r--synapse/config/appservice.py14
1 files changed, 10 insertions, 4 deletions
diff --git a/synapse/config/appservice.py b/synapse/config/appservice.py
index 00182090b2..fd89960e72 100644
--- a/synapse/config/appservice.py
+++ b/synapse/config/appservice.py
@@ -33,6 +33,16 @@ class AppServiceConfig(Config):
 
     def read_config(self, config: JsonDict, **kwargs: Any) -> None:
         self.app_service_config_files = config.get("app_service_config_files", [])
+        if not isinstance(self.app_service_config_files, list) or not all(
+            type(x) is str for x in self.app_service_config_files
+        ):
+            # type-ignore: this function gets arbitrary json value; we do use this path.
+            raise ConfigError(
+                "Expected '%s' to be a list of AS config files:"
+                % (self.app_service_config_files),
+                "app_service_config_files",
+            )
+
         self.track_appservice_user_ips = config.get("track_appservice_user_ips", False)
 
 
@@ -40,10 +50,6 @@ def load_appservices(
     hostname: str, config_files: List[str]
 ) -> List[ApplicationService]:
     """Returns a list of Application Services from the config files."""
-    if not isinstance(config_files, list):
-        # type-ignore: this function gets arbitrary json value; we do use this path.
-        logger.warning("Expected %s to be a list of AS config files.", config_files)  # type: ignore[unreachable]
-        return []
 
     # Dicts of value -> filename
     seen_as_tokens: Dict[str, str] = {}