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:
Jason Little 2025-09-09 03:50:09 -05:00 committed by GitHub
parent dfccde9f60
commit 4d55f2f301
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 3 additions and 2 deletions

1
changelog.d/18874.misc Normal file
View File

@ -0,0 +1 @@
Use the `Enum`'s value for the dictionary key when responding to an admin request for experimental features.

View File

@ -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(