-
Notifications
You must be signed in to change notification settings - Fork 429
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: add endpoint to list (edge) identity overrides for a feature #3116
feat: add endpoint to list (edge) identity overrides for a feature #3116
Conversation
…feature-in-edge # Conflicts: # api/app/settings/common.py # api/environments/dynamodb/dynamodb_wrapper.py
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
Uffizzi Preview |
Codecov ReportAttention:
Additional details and impacted files@@ Coverage Diff @@
## main #3116 +/- ##
==========================================
+ Coverage 95.95% 96.08% +0.13%
==========================================
Files 1053 1054 +1
Lines 31588 31693 +105
==========================================
+ Hits 30311 30453 +142
+ Misses 1277 1240 -37 ☔ View full report in Codecov by Sentry. |
identity: EdgeIdentity = self.parent.context["identity"] | ||
environment: Environment = self.parent.context["environment"] | ||
identity_id = identity.get_hash_key( | ||
environment.use_identity_composite_key_for_hashing | ||
) | ||
|
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.
This is technically out of the scope of this PR, but this was an issue in the current implementation of the views which retrieve the feature states for a given identity.
The previous logic, although wrong, wouldn't have actually given any incorrect data (at least for users that are creating identity overrides via the dashboard, not via the API) since it only would have affected multivariate features with more than one weighted option, which we don't allow for identity overrides (you have to select a single option, which will be given 100% weighting).
Since I had to also implement this functionality for the new endpoint, however, it made sense to fix it in this PR.
@@ -142,4 +143,9 @@ | |||
create_segment_override, | |||
name="create-segment-override", | |||
), | |||
path( | |||
"<int:environment_pk>/edge-identity-overrides", |
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.
I'm not sure whether to use the pk
here or the API key. I definitely prefer using the pk, and would like to move to using the pk
everywhere in the future so I figured this would at least not add further tech debt. It does, however, cause some consistency issues.
@@ -183,6 +183,7 @@ def save(self, user: FFAdminUser = None, master_api_key: MasterAPIKey = None): | |||
"environment_api_key": self.environment_api_key, | |||
"changes": changes, | |||
"identity_uuid": str(self.identity_uuid), | |||
"identifier": self.identifier, |
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.
@khvn26, I had to add the identifier here as I need it in the response to the FE. I believe we'll also need it to power identity override in local evaluation too so I think it's data worth having.
Changes
Fixes #3105.
Uses the new
flagsmith_environments_v2
(based on the structure defined here) to generate a view to show all the identity overrides for a particular feature.Adds an endpoint at
GET /api/v1/environments/:environment_id/edge-identity-overrides[?feature=:feature_id]
which returns data in the following structure:How did you test this code?
Added tests to the codebase where necessary. Also tested the dynamo integrations manually to confirm the data is returned as expected.
I've also run my local API against staging dynamo and inserted data into the
flagsmith_environments_v2
table and verified that the endpoint picks up the data as expected.