fix(API): _validate_owner_removal counts non-existent group IDs as removals - #8137
Conversation
…movals A remove-group-owners request whose group_ids include a stale or non-existent group ID inflated the removal count, blocking a legitimate removal of the real group when enforce_feature_owners is on. Count only IDs that are actually current owners of the feature.
|
@bardock-2393 is attempting to deploy a commit to the Flagsmith Team on Vercel. A member of the Team first needs to authorize it. |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Pro Plus Run ID: 📒 Files selected for processing (2)
📝 WalkthroughWalkthroughThe owner removal endpoints now pass requested user and group ID iterables to Estimated code review effort: 2 (Simple) | ~10 minutes Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
docs/if required so people know about the feature.Changes
When
enforce_feature_ownersis on, removing group owners from a feature could be wrongly rejected with a 400 if the request included a stale or non-existent group ID alongside a real one. The validation counted every ID in the request as a removal, instead of only the IDs that were actually current owners, so a harmless extra ID could make it look like the last owner was being removed.Contributes to #8038
_validate_owner_removalnow counts only the requested IDs that are actually current owners/group owners of the feature, instead of trusting the request's ID count.How did you test this code?
Added a regression test (
test_remove_group_owners__enforce_owners_nonexistent_group_id_in_request__returns_200) reproducing the issue's exact scenario: a feature with one user owner and one group owner, removing the group owner while also passing a non-existent group ID. Verified it fails with400against the old code and passes with the fix. Ran the fulltest_unit_features_views.pysuite (298 passed, 2 pre-existing skips), plusmypyand the project's lint/format pre-commit hooks, all clean.Review effort: 1/5