Add API-level filtering to exclude AGENT userstore from GET /userstores endpoint#1148
Add API-level filtering to exclude AGENT userstore from GET /userstores endpoint#1148ruchiralakshan123 wants to merge 2 commits into
Conversation
|
Warning Review limit reached
Next review available in: 32 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughThe Sequence Diagram(s)sequenceDiagram
participant Client
participant UserstoresApiServiceImpl
participant serverUserStoreService
Client->>UserstoresApiServiceImpl: Request userstores with exclusion enabled
UserstoresApiServiceImpl->>serverUserStoreService: Retrieve userstore list
serverUserStoreService-->>UserstoresApiServiceImpl: Return userstore list
UserstoresApiServiceImpl-->>Client: Return list without AGENT
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
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 |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
components/org.wso2.carbon.identity.api.server.userstore/org.wso2.carbon.identity.api.server.userstore.v1/src/main/java/org/wso2/carbon/identity/api/server/userstore/v1/impl/UserstoresApiServiceImpl.java (1)
111-119: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueConsider using Streams for filtering.
The filtering logic can be simplified using Java Streams for better readability.
♻️ Proposed refactor
- if (Boolean.TRUE.equals(excludeAgentUserstore) && userStoreList != null) { - List<UserStoreListResponse> filteredUserStores = new ArrayList<>(); - for (UserStoreListResponse userStore : userStoreList) { - if (!"AGENT".equalsIgnoreCase(userStore.getName())) { - filteredUserStores.add(userStore); - } - } - return Response.ok().entity(filteredUserStores).build(); - } + if (Boolean.TRUE.equals(excludeAgentUserstore) && userStoreList != null) { + List<UserStoreListResponse> filteredUserStores = userStoreList.stream() + .filter(userStore -> !"AGENT".equalsIgnoreCase(userStore.getName())) + .collect(java.util.stream.Collectors.toList()); + return Response.ok().entity(filteredUserStores).build(); + }🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@components/org.wso2.carbon.identity.api.server.userstore/org.wso2.carbon.identity.api.server.userstore.v1/src/main/java/org/wso2/carbon/identity/api/server/userstore/v1/impl/UserstoresApiServiceImpl.java` around lines 111 - 119, Refactor the filtering branch in UserstoresApiServiceImpl to use a Java Stream over userStoreList, retaining only entries whose names are not equal to “AGENT” case-insensitively, then build the response from the collected list. Preserve the existing null check, excludeAgentUserstore condition, and response behavior.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In
`@components/org.wso2.carbon.identity.api.server.userstore/org.wso2.carbon.identity.api.server.userstore.v1/src/main/java/org/wso2/carbon/identity/api/server/userstore/v1/impl/UserstoresApiServiceImpl.java`:
- Around line 111-119: Refactor the filtering branch in UserstoresApiServiceImpl
to use a Java Stream over userStoreList, retaining only entries whose names are
not equal to “AGENT” case-insensitively, then build the response from the
collected list. Preserve the existing null check, excludeAgentUserstore
condition, and response behavior.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 95dbc1d0-80a4-4232-a266-367f0737299e
⛔ Files ignored due to path filters (2)
components/org.wso2.carbon.identity.api.server.userstore/org.wso2.carbon.identity.api.server.userstore.v1/src/gen/java/org/wso2/carbon/identity/api/server/userstore/v1/UserstoresApi.javais excluded by!**/gen/**components/org.wso2.carbon.identity.api.server.userstore/org.wso2.carbon.identity.api.server.userstore.v1/src/gen/java/org/wso2/carbon/identity/api/server/userstore/v1/UserstoresApiService.javais excluded by!**/gen/**
📒 Files selected for processing (2)
components/org.wso2.carbon.identity.api.server.userstore/org.wso2.carbon.identity.api.server.userstore.v1/src/main/java/org/wso2/carbon/identity/api/server/userstore/v1/impl/UserstoresApiServiceImpl.javacomponents/org.wso2.carbon.identity.api.server.userstore/org.wso2.carbon.identity.api.server.userstore.v1/src/main/resources/userstore.yaml
Purpose
Currently, the
AGENTuserstore appears in UI selection dropdowns across various features (such as JIT provisioning, user attribute mappings, etc.) where it should not be selectable. UI components are implementing ad-hoc hardcoded filtering logic to exclude it, which is not scalable.This PR introduces an optional query parameter
excludeAgentUserstoreto theGET /api/server/v1/userstoresendpoint to exclude theAGENTuserstore at the API level.Resolves: wso2/product-is#27435
Goals
Exclude the
AGENTuserstore at the API level from the/userstoresGET endpoint response when requested.Approach
userstore.yaml) to introduce a new boolean query parameterexcludeAgentUserstore(default:falsefor backward compatibility).UserstoresApi.javaandUserstoresApiService.javato support the new parameter.UserstoresApiServiceImpl.javato filter out any userstores with the name"AGENT"(case-insensitive) from the returned list whenexcludeAgentUserstoreis set totrue.User stories
N/A
Developer Checklist (Mandatory)
product-isissue to track any behavioral change or migration impact.Release note
Added a new query parameter
excludeAgentUserstoreto the/userstoresAPI to exclude theAGENTuserstore at the API level.Documentation
N/A - This is a self-documented API query parameter in the OpenAPI spec.
Training
N/A
Certification
N/A
Marketing
N/A
Automation tests
Security checks
Samples
N/A
Related PRs
N/A
Migrations (if applicable)
N/A
Test environment
Learning
Standard JAX-RS REST API development patterns and Swagger/OpenAPI code-generation workflows within the WSO2 identity-api-server repository.