-
Notifications
You must be signed in to change notification settings - Fork 30
fix(flags): remove lower()
when evaluating feature flag payloads – these payloads are case-sensitive!
#191
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PR Summary
This PR addresses case sensitivity inconsistencies in PostHog's Python client feature flag handling, ensuring uniform case-insensitive flag key matching.
- Modified
get_feature_flag()
in/posthog/client.py
to normalize flag keys to lowercase for consistent evaluation - Added case-insensitive payload retrieval logic in
_compute_payload_locally()
to match flag evaluation behavior - Added test cases in
/posthog/test/test_feature_flags.py
to verify mixed-case flag keys work correctly for both evaluation and payload retrieval - Fixed issue Feature flag evaluation is case sensitive, while feature flag payload match evaluation is evaluated as lower() #178 where flag evaluation and payload retrieval had inconsistent case sensitivity handling
2 file(s) reviewed, 1 comment(s)
Edit PR Review Bot Settings | Greptile
I looked at the linked issue #178:
I think the payload evaluation with As an aside, I think allowing case sensitivity in flag keys is probably not ideal. But changing that is challenging if anybody has duplicate keys. But there are ways we could handle that, such as making it an unexposed project setting. All new projects (and old projects with no duplicates) have case-insensitive keys. |
Some more context. In posthog-python/posthog/client.py Line 881 in 6764c78
payload = flag_payloads.get(str(match_value).lower(), None) Which I think may be wrong as well. However, it's tricky because |
lower()
when evaluating feature flag payloads – these payloads are case-sensitive!
Remove
lower()
when evaluating feature flags + feature flag payloads – feature flags are case-sensitive. Closes #178