Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changelog.d/19987.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix config regression around falsy `experimental_features` no longer being accepted.
7 changes: 4 additions & 3 deletions synapse/config/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -966,9 +966,10 @@ def read_config(self, config: JsonDict, **kwargs: Any) -> None:

# 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 {}

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This matches what we already do:

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
Expand Down
71 changes: 71 additions & 0 deletions tests/config/test_experimental.py
Original file line number Diff line number Diff line change
@@ -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 changes: 24 additions & 0 deletions tests/config/test_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -228,6 +229,29 @@ def generate_config(value: Any) -> JsonDict:
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(
Expand Down
Loading