Fix config regression around falsy experimental_features (None) (#19987)

Fix https://github.com/element-hq/synapse/issues/19986

Regressed in https://github.com/element-hq/synapse/pull/19539
This commit is contained in:
Eric Eastwood authored and GitHub committed 2026-07-22 09:07:29 -05:00
1 parent e0f251ce2c
commit 7cb94ab266
4 files changed
+100 -3

No files matched your search

+1
View File
@@ -0,0 +1 @@
Fix config regression around falsy `experimental_features` no longer being accepted.
+4 -3
View File
@@ -966,9 +966,10 @@ class ServerConfig(Config):
# The maximum number of delayed events a user may have scheduled at a time.
# (Defined here despite being experimental to be near the other MSC4140 config)
self.max_delayed_events_per_user: int = config.get(
"experimental_features", {}
).get("msc4140_max_delayed_events_per_user", 100)
experimental = config.get("experimental_features") or {}
self.max_delayed_events_per_user: int = experimental.get(
"msc4140_max_delayed_events_per_user", 100
)
if (
not isinstance(self.max_delayed_events_per_user, int)
or self.max_delayed_events_per_user < 0
+71
View File
@@ -0,0 +1,71 @@
#
# This file is licensed under the Affero General Public License (AGPL) version 3.
#
# Copyright (C) 2026 Element Creations Ltd.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# See the GNU Affero General Public License for more details:
# <https://www.gnu.org/licenses/agpl-3.0.html>.
import yaml
from parameterized import parameterized
from synapse.config._base import RootConfig
from synapse.config.experimental import ExperimentalConfig
from synapse.config.homeserver import HomeServerConfig
from synapse.types import JsonDict
from tests import unittest
class ExperimentalConfigTestCase(unittest.TestCase):
@parameterized.expand(
[
[
"single",
{
"experimental_features": {
"msc3575_enabled": True,
}
},
],
[
"multi",
{
"experimental_features": {
"msc3575_enabled": True,
"msc3030_enabled": True,
}
},
],
# This has historically worked and this is being added as a regression test
["none", {"experimental_features": None}],
]
)
def test_experimental_features_parsing(
self, test_description: str, config_values: JsonDict
) -> None:
"""
Test the that `experimental_features` parses with these values
"""
_read_config(config_values)
def _read_config(config_values: JsonDict) -> None:
ExperimentalConfig(RootConfig()).read_config(
yaml.safe_load(
HomeServerConfig().generate_config(
config_dir_path="CONFDIR",
data_dir_path="/data_dir_path",
server_name="che.org",
)
)
| config_values,
allow_secrets_in_config=False,
)
+24
View File
@@ -22,6 +22,7 @@
from typing import Any
import yaml
from parameterized import parameterized
from synapse.config._base import ConfigError, RootConfig
from synapse.config.homeserver import HomeServerConfig
@@ -228,6 +229,29 @@ class ServerConfigTestCase(unittest.TestCase):
with self.assertRaises(ConfigError):
_read_config(generate_config(disallowed_value))
@parameterized.expand(
[
[
"single",
{
"experimental_features": {
"msc4140_max_delayed_events_per_user": 3,
}
},
],
# This has historically worked and this is being added as a regression test
["none", {"experimental_features": None}],
]
)
def test_experimental_features_parsing(
self, test_description: str, config_values: JsonDict
) -> None:
"""
Test the that `experimental_features` parses with these values
"""
_read_config(config_values)
def _read_config(config_values: JsonDict) -> None:
ServerConfig(RootConfig()).read_config(