Skip to content

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

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

vjymisal0 wants to merge 3 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
@sonarqubecloud

Copy link
Copy Markdown

@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.

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.

2 participants