Skip to content
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

feat(flags): remove Unleash get_variant patching code #3914

Draft
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

aliu39
Copy link
Member

@aliu39 aliu39 commented Jan 10, 2025

Follow-up to #3888

Fixing logic error:
After rereading https://docs.getunleash.io/reference/strategy-variants and testing w/ a local Unleash instance, I found we need to use a different variant field, feature_enabled. enabled refers to whether the variant itself is enabled, but a feature/"toggle" can be enabled with no variants. In this case, a disabled variant is returned (see no_variant_payload in tests).


Update:
The original PR patched 2 methods used for evaluating feature flags, is_enabled (simple toggle on/off) and get_variant (returns a dict of metadata, see https://docs.getunleash.io/reference/sdks/python#getting-a-variant).
We want to remove all get_variant code since we only support boolean flag evals atm. It seems like Unleash's main usecase for variants is reading payloads (non-bool) for A/B/multivariate testing. This could lead to a lot of extraneous flags, so until it is requested and/or we support non-bool values, let's not patch this method.

Copy link

codecov bot commented Jan 10, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 80.17%. Comparing base (fa241c3) to head (7c40943).

✅ All tests successful. No failed tests found.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #3914      +/-   ##
==========================================
- Coverage   80.20%   80.17%   -0.03%     
==========================================
  Files         140      140              
  Lines       15412    15403       -9     
  Branches     2593     2593              
==========================================
- Hits        12361    12350      -11     
- Misses       2206     2207       +1     
- Partials      845      846       +1     
Files with missing lines Coverage Δ
sentry_sdk/integrations/unleash.py 91.30% <ø> (-2.45%) ⬇️

... and 3 files with indirect coverage changes

@cmanallen
Copy link
Member

@aliu39 How are people using get_variant in practice? Does it make sense to send a true, false value to Sentry if what the user is actually working with strings a, b, or c?

@aliu39 aliu39 changed the title fix(flags): use feature_enabled field of unleash variants feat(flags): revert get_variant patching code Jan 10, 2025
@aliu39
Copy link
Member Author

aliu39 commented Jan 10, 2025

@aliu39 How are people using get_variant in practice? Does it make sense to send a true, false value to Sentry if what the user is actually working with strings a, b, or c?

Discussed on a call, also looping in the FFs slack channel

@aliu39 aliu39 marked this pull request as draft January 10, 2025 18:31
@aliu39 aliu39 changed the title feat(flags): revert get_variant patching code feat(flags): remove get_variant patching code Jan 10, 2025
@aliu39 aliu39 changed the title feat(flags): remove get_variant patching code feat(flags): remove Unleash get_variant patching code Jan 10, 2025
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.

2 participants