Skip to content

fix: filter-based bulk user delete no longer capped to first page of 20 users - #7067

Merged
Shivam-nagar23 merged 1 commit into
mainfrom
fix/bulk-delete-show-all
Oct 23, 2026
Merged

Shivam-nagar23 merged 1 commit into
mainfrom
fix/bulk-delete-show-all

Conversation

@claude

@claude claude Bot commented Oct 23, 2026

Copy link
Copy Markdown

Requested by Shivam Nagar · Slack thread

Description

Fixes #7066

Before: a filter-based bulk delete (e.g. {"listingRequest":{"searchKey":"abc"}} with no explicit ids) resolved only the first page of 20 matching users and silently left the rest in place.

After: a filter-based bulk delete resolves every matching user, as the listing filter implies.

How: getUserIdsHonoringFilters (pkg/auth/user/UserService.go) applies the listing normalization, which defaults Size to bean.DefaultSize (20); GetQueryForUserListingWithFilters then appends limit ? offset ? unless ShowAll is set. The fix sets request.ShowAll = true after the normalization calls and before the query is built, with an explanatory comment. The same fix landed in devtron-enterprise via devtron-labs/devtron-enterprise#3407. GetAllWithFilters, the query builder and the explicit-ids delete path are unchanged.

How Has This Been Tested?

Extended pkg/auth/user/UserService_bulkdelete_filter_test.go:

  • TestGetUserIdsHonoringFilters_DoesNotPaginate (new): 25 matching users (more than the default page size of 20) all get resolved, ShowAll is forced true, and the query has no limit ? offset ? and no bound page size. It also builds the pre-fix query (same input, no ShowAll) and asserts it is paginated with the default page size, so the test fails if the fix is reverted.
  • TestGetUserIdsHonoringFilters_MatchesListingQuery (updated): the listing path paginates by default while the delete path intentionally does not, so the expected listing query is now built with ShowAll = true.
  • TestGetUserIdsHonoringFilters_RejectsUnscopedFilter: unchanged.

go build ./pkg/auth/user/... succeeds. go test ./pkg/auth/user/ -run TestGetUserIdsHonoringFilters -v -vet=off passes all three tests, and temporarily removing the ShowAll = true line makes the new and updated tests fail. As with #7021, pkg/auth/user/UserService_test.go and UserFlows_test.go already fail to compile on main (stale NewUserCommonServiceImpl signature etc.), so I temporarily moved them aside to run the tests; they are restored and not part of this change. gofmt -l is clean.

Checklist:

  • The title of the PR states what changed and the related issues number (used for the release note).
  • Does this PR requires documentation updates?
  • I've updated documentation as required by this PR.
  • I have performed a self-review of my own code.
  • I have commented my code, particularly in hard-to-understand areas.
  • I have tested it for all user roles.
  • I have added all the required unit/api test cases.

Does this PR introduce a user-facing change?

Fixed a bug where a filter-based bulk user delete only deleted the first 20 matching users and silently left the rest. It now applies to every user matching the filter.

Generated by Claude Code

…20 users

getUserIdsHonoringFilters applied the listing default page size (20) and the
query builder then appended "limit ? offset ?", so a filter-based bulk delete
only resolved the first 20 matching users. Force ShowAll so the delete applies
to every matching user. Adds regression tests.

Fixes #7066

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01J5DesTG5XvPdmPCDuL6izq
@bito-code-review

Copy link
Copy Markdown

Bito Automatic Review Skipped - Draft PR

Bito didn't auto-review because this pull request is in draft status.
No action is needed if you didn't intend for the agent to review it. Otherwise, to manually trigger a review, type /review in a comment and save.
You can change draft PR review settings here, or contact your Bito workspace admin at shivam@devtron.ai.

@claude
claude Bot marked this pull request as ready for review October 23, 2026 12:19
@sonarqubecloud

Copy link
Copy Markdown

@Shivam-nagar23
Shivam-nagar23 merged commit d12a1cf into main Oct 23, 2026
10 checks passed
@Shivam-nagar23
Shivam-nagar23 deleted the fix/bulk-delete-show-all branch October 23, 2026 12:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Filter-based bulk user delete silently capped to the first page (20 users)

3 participants