[73431] SCIM user api return duplicate records#22514
Open
cholarajaa wants to merge 5 commits intoopf:devfrom
Open
[73431] SCIM user api return duplicate records#22514cholarajaa wants to merge 5 commits intoopf:devfrom
cholarajaa wants to merge 5 commits intoopf:devfrom
Conversation
The index action on the SCIM users endpoint was returning duplicate records when a user belonged to multiple groups or had multiple auth provider links. This happened because storage_scope uses left_joins, which produces one row per join match. Added .distinct to the index query to eliminate duplicates. Also extracted scim_index_storage_query and scim_all_attribute_names into their own private methods for better readability.
Adds request specs for the SCIM v2 users index endpoint to make sure each user is returned only once, even with multiple group memberships or auth provider links. Covers the duplicate-record regression caused by joined relations.
|
All contributors have signed the CLA ✍️ ✅ |
Author
|
recheck |
Author
|
I have read the CLA Document and I hereby sign the CLA |
Author
|
recheck |
Author
|
@NobodysNightmare Please review. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Ticket
https://community.openproject.org/projects/openproject/work_packages/73431
What are you trying to accomplish?
Fix duplicate records in the SCIM v2 Users API index response.
This PR includes:
[#73431] Fix SCIM v2 user API returning duplicate records
[#73431] Add tests for duplicate SCIM v2 user results
Users could appear multiple times in SCIM index results when they had multiple group memberships or multiple auth provider links.
Screenshots
N/A — backend API change (no UI changes).
What approach did you choose and why?
I added .distinct to the SCIM index query path to ensure each user is returned only once, even when left_joins expands rows through related tables.
I also extracted small helper methods (scim_index_storage_query, scim_all_attribute_names) to keep the action easier to read and maintain.
I added request specs to cover the regression and verify that duplicate users are not returned.
Merge checklist