mirror of
https://github.com/element-hq/synapse.git
synced 2025-12-08 00:00:52 -05:00
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.
This commit is contained in:
parent
dfccde9f60
commit
4d55f2f301
1
changelog.d/18874.misc
Normal file
1
changelog.d/18874.misc
Normal file
@ -0,0 +1 @@
|
|||||||
|
Use the `Enum`'s value for the dictionary key when responding to an admin request for experimental features.
|
||||||
@ -92,9 +92,9 @@ class ExperimentalFeaturesRestServlet(RestServlet):
|
|||||||
user_features = {}
|
user_features = {}
|
||||||
for feature in ExperimentalFeature:
|
for feature in ExperimentalFeature:
|
||||||
if feature in enabled_features:
|
if feature in enabled_features:
|
||||||
user_features[feature] = True
|
user_features[feature.value] = True
|
||||||
else:
|
else:
|
||||||
user_features[feature] = False
|
user_features[feature.value] = False
|
||||||
return HTTPStatus.OK, {"features": user_features}
|
return HTTPStatus.OK, {"features": user_features}
|
||||||
|
|
||||||
async def on_PUT(
|
async def on_PUT(
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user