Conversation
There was a problem hiding this comment.
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.pyto 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.pyto verify mixed-case flag keys work correctly for both evaluation and payload retrieval - Fixed issue #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