Skip to content

fix(auth,appstore): eliminate redundant query branches and optimize batch role lookups - #7025

Open
vjymisal0 wants to merge 6 commits into
devtron-labs:mainfrom
vjymisal0:fix/auth-appstore-redundant-branches-and-queries
Open

vjymisal0 wants to merge 6 commits into
devtron-labs:mainfrom
vjymisal0:fix/auth-appstore-redundant-branches-and-queries

Conversation

@vjymisal0

Copy link
Copy Markdown

Summary of Changes

This PR optimizes role verification logic and adds batch user status filtering:

  1. Refactored RBAC Role Check in UserCommonService.go:
    • Streamlined redundant conditional branching when verifying whether a role matches specified entity/action criteria.
    • Cleaned up duplicate mapping lookups for admin and manager role validations.
  2. Batch User Filtering in UserRepository.go:
    • Added FilterActiveUserIds helper to batch-filter active users in-memory from user models, avoiding unnecessary round-trips.
  3. Comprehensive Unit Tests:
    • Added pkg/auth/user/UserCommonService_test.go to test role evaluation permutations.
    • Added pkg/auth/user/repository/UserRepository_test.go for active user filtering edge cases (empty slices, all inactive, mixed).
    • Added pkg/appStore/installedApp/service/common/AppStoreDeploymentCommonService_test.go covering deployment validation helpers.

Files Changed

  • pkg/auth/user/UserCommonService.go
  • pkg/auth/user/repository/UserRepository.go
  • pkg/auth/user/UserCommonService_test.go
  • pkg/auth/user/repository/UserRepository_test.go
  • pkg/appStore/installedApp/service/common/AppStoreDeploymentCommonService_test.go

@bito-code-review

Copy link
Copy Markdown

Bito Review Skipped - Source Branch Not Found

Bito didn't review this change because the pull request is no longer valid. It may have been merged, or the source/target branch may no longer exist.

Comment thread pkg/appStore/installedApp/service/common/AppStoreDeploymentCommonService_test.go Outdated
Comment thread pkg/auth/user/repository/UserRepository.go Outdated
Comment thread pkg/auth/user/repository/UserRepository_test.go Outdated
@vjymisal0

Copy link
Copy Markdown
Author

Removed the unused FilterActiveUserIds helper and its associated unit test in commit 12cb36e.

@vjymisal0

Copy link
Copy Markdown
Author

Thanks for the review. I followed up on those points in commit 12cb36e727564194cf4adea8d0fbb7d4692da209: the unused FilterActiveUserIds helper and its associated test are removed, so the remaining diff is limited to the intended auth/appstore changes.

@vjymisal0

Copy link
Copy Markdown
Author

Pushed the cleanup. The unrelated appstore helper test is gone now, and the unused FilterActiveUserIds helper/test were already removed in the previous update.

@vjymisal0
vjymisal0 force-pushed the fix/auth-appstore-redundant-branches-and-queries branch from 8bf1924 to b5d80e2 Compare September 16, 2026 10:22
@vjymisal0

Copy link
Copy Markdown
Author

Reviewed the latest PR state and the available checks. SonarQube reports a passed quality gate with 0 new issues, 0 accepted issues, and 0 security hotspots. I did not make additional changes because no maintainer action was requested; the Bito review was skipped due to a source-branch lookup issue. A local Go test was not runnable because Go is not installed in this environment.

@vjymisal0

Copy link
Copy Markdown
Author

Thanks for the review @Shivam-nagar23. The unrelated appstore test and unused repository helper/test you flagged have been removed; the current diff is limited to UserCommonService.go and its test. Could you take another look and dismiss the old changes-requested review if the cleanup now addresses your concerns?

Copilot AI balanced review requested due to automatic review settings October 8, 2026 15:10

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

Copilot AI balanced review requested due to automatic review settings October 27, 2026 12:18

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota.

An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing. Review the Copilot code review billing settings.

@sonarqubecloud

Copy link
Copy Markdown

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants