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

fix: Cannot use an API Key to add users to a group #4362

Merged
merged 4 commits into from
Jul 23, 2024

Conversation

matthewelwell
Copy link
Contributor

Changes

Fixes #4361

How did you test this code?

Added a new test for the specific failure case and also updated the test module to use admin_client_new in all tests and resolved any other similar issues.

@matthewelwell matthewelwell requested a review from a team as a code owner July 19, 2024 13:45
@matthewelwell matthewelwell requested review from gagantrivedi and removed request for a team July 19, 2024 13:45
Copy link

vercel bot commented Jul 19, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

3 Skipped Deployments
Name Status Preview Comments Updated (UTC)
docs ⬜️ Ignored (Inspect) Jul 23, 2024 2:47pm
flagsmith-frontend-preview ⬜️ Ignored (Inspect) Jul 23, 2024 2:47pm
flagsmith-frontend-staging ⬜️ Ignored (Inspect) Visit Preview Jul 23, 2024 2:47pm

Copy link

sentry-io bot commented Jul 19, 2024

🔍 Existing Issues For Review

Your pull request is modifying functions with the following pre-existing issues:

📄 File: api/users/views.py

Function Unhandled Issue
add_users AttributeError: 'APIKeyUser' object has no attribute 'is_group_admin' /api/v1/organisations/{organisation_pk}/g...
Event Count: 6
add_users TypeError: sequence item 0: expected str instance, FFAdminUser found /api/v1/organisations/{organisation_pk}/gr...
Event Count: 3

Did you find this useful? React with a 👍 or 👎

@github-actions github-actions bot added api Issue related to the REST API fix labels Jul 19, 2024
Copy link
Contributor

github-actions bot commented Jul 19, 2024

Docker builds report

Image Build Status Security report
ghcr.io/flagsmith/flagsmith-api-test:pr-4362 Finished ✅ Skipped
ghcr.io/flagsmith/flagsmith-e2e:pr-4362 Finished ✅ Skipped
ghcr.io/flagsmith/flagsmith-frontend:pr-4362 Finished ✅ Results
ghcr.io/flagsmith/flagsmith-api:pr-4362 Finished ✅ Results
ghcr.io/flagsmith/flagsmith-private-cloud:pr-4362 Finished ✅ Results

Copy link
Contributor

github-actions bot commented Jul 19, 2024

Uffizzi Preview deployment-54402 was deleted.

Copy link

codecov bot commented Jul 19, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 96.79%. Comparing base (b31bd8c) to head (71de795).
Report is 5 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #4362   +/-   ##
=======================================
  Coverage   96.79%   96.79%           
=======================================
  Files        1162     1162           
  Lines       38239    38248    +9     
=======================================
+ Hits        37012    37021    +9     
  Misses       1227     1227           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@khvn26
Copy link
Member

khvn26 commented Jul 23, 2024

Can we accommodate edge_api.identities.tasks.call_environment_webhook_for_feature_state_change and fix #4370 as part of this PR as well?

@github-actions github-actions bot added fix and removed fix labels Jul 23, 2024
@matthewelwell
Copy link
Contributor Author

Can we accommodate edge_api.identities.tasks.call_environment_webhook_for_feature_state_change and fix #4370 as part of this PR as well?

Well, strictly, that would involve changing the branch name and recreating the PR, etc. - I can do it, but at that point, we might as well just create a new PR?

@khvn26
Copy link
Member

khvn26 commented Jul 23, 2024

Well, strictly, that would involve changing the branch name and recreating the PR, etc

Or just changing the PR description to "Fixes #4361, #4370"?

@matthewelwell
Copy link
Contributor Author

Well, strictly, that would involve changing the branch name and recreating the PR, etc

Or just changing the PR description to "Fixes #4361, #4370"?

Hence 'strictly'. It's ugly to not change the branch name, but I can. I guess the branch name doesn't live anywhere post merge so it's fine. I'll just do it, yep.

@matthewelwell
Copy link
Contributor Author

Actually @khvn26, sorry, but no, #4370 is actually quite a bit more involved as it breaks the webhook schema. If you look here, we're currently always sending the email of the user that made the change. We will no longer have that option available to us.

Based on this, I'd say it definitely deserves its own PR.

@matthewelwell matthewelwell added this pull request to the merge queue Jul 23, 2024
Merged via the queue into main with commit 0390075 Jul 23, 2024
34 checks passed
@matthewelwell matthewelwell deleted the fix/api-key-add-group-users branch July 23, 2024 15:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api Issue related to the REST API fix
Projects
None yet
Development

Successfully merging this pull request may close these issues.

AttributeError: 'APIKeyUser' object has no attribute 'is_group_admin'
2 participants