Skip to content

fix: Return 401 instead of 500 when X-Environment-Key is missing - #201

Open
ash-vd wants to merge 1 commit into
Flagsmith:mainfrom
ash-vd:fix/missing-environment-key-500
Open

ash-vd wants to merge 1 commit into
Flagsmith:mainfrom
ash-vd:fix/missing-environment-key-500

Conversation

@ash-vd

@ash-vd ash-vd commented Oct 14, 2026 •

Copy link
Copy Markdown

Since #182, get_flags_response_data and get_identity_response_data call environment_key.startswith() before get_environment(), so a request without an X-Environment-Key header raises AttributeError and returns a
500. Up to 2.21.2 the same request got a 401 from get_environment().

Check for a missing key first and raise FlagsmithUnknownKeyError, the same response the environment document endpoint gives.

Since Flagsmith#182, get_flags_response_data and get_identity_response_data call
environment_key.startswith() before get_environment(), so a request
without an X-Environment-Key header raises AttributeError and returns a
500. Up to 2.21.2 the same request got a 401 from get_environment().

Check for a missing key first and raise FlagsmithUnknownKeyError, the
same response the environment document endpoint gives.
@ash-vd
ash-vd requested a review from a team as a code owner October 14, 2026 06:52
@ash-vd
ash-vd requested review from khvn26 and removed request for a team October 14, 2026 06:52
@ash-vd ash-vd changed the title fix: return 401 instead of 500 when X-Environment-Key is missing fix: Return 401 instead of 500 when X-Environment-Key is missing Oct 14, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant