From 4d55f2f3017f5307d50808634ac1d563313fa8da Mon Sep 17 00:00:00 2001 From: Jason Little Date: Tue, 9 Sep 2025 03:50:09 -0500 Subject: [PATCH] fix: Use the `Enum`'s value for the dictionary key when responding to an admin request for experimental features (#18874) While exploring bring up of using `orjson`, exposed an interesting flaw. The stdlib `json` encoder seems to be ok with coercing a `str` from an `Enum`(specifically, a `Class[str, Enum]`). The `orjson` encoder does not like that this is a class and not a proper `str` per spec. Using the `.value` of the enum as the key for the dict produced while answering a `GET` admin request for experimental features seems to fix this. --- changelog.d/18874.misc | 1 + synapse/rest/admin/experimental_features.py | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) create mode 100644 changelog.d/18874.misc diff --git a/changelog.d/18874.misc b/changelog.d/18874.misc new file mode 100644 index 0000000000..729befb5e8 --- /dev/null +++ b/changelog.d/18874.misc @@ -0,0 +1 @@ +Use the `Enum`'s value for the dictionary key when responding to an admin request for experimental features. diff --git a/synapse/rest/admin/experimental_features.py b/synapse/rest/admin/experimental_features.py index afb71f4a0f..3d3015cef7 100644 --- a/synapse/rest/admin/experimental_features.py +++ b/synapse/rest/admin/experimental_features.py @@ -92,9 +92,9 @@ class ExperimentalFeaturesRestServlet(RestServlet): user_features = {} for feature in ExperimentalFeature: if feature in enabled_features: - user_features[feature] = True + user_features[feature.value] = True else: - user_features[feature] = False + user_features[feature.value] = False return HTTPStatus.OK, {"features": user_features} async def on_PUT(