[PR #7899] [CLOSED] fix(admin): handle falsy filter values in listUsers #7620

Closed
opened 2026-03-13 13:43:18 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/better-auth/better-auth/pull/7899
Author: @jayy-77
Created: 2/10/2026
Status: Closed

Base: canaryHead: fix/admin-listusers-falsy-filter-7837


📝 Commits (1)

  • 96af628 fix(admin): handle falsy filter values in listUsers

📊 Changes

2 files changed (+60 additions, -1 deletions)

View changed files

📝 packages/better-auth/src/plugins/admin/admin.test.ts (+59 -0)
📝 packages/better-auth/src/plugins/admin/routes.ts (+1 -1)

📄 Description

Problem

The listUsers admin route uses a truthy check (if (ctx.query?.filterValue)) to decide whether to apply a filter. This silently drops valid falsy values like false, 0, and empty string "", making it impossible to filter by e.g. banned = false.

Changes

  • Changed the condition from if (ctx.query?.filterValue) to if (ctx.query?.filterValue !== undefined) so falsy values are correctly passed through to the query builder.
  • Added edge-case tests for:
    • Filtering by boolean false (banned = false)
    • Filtering by numeric 0
    • Default filterField fallback when not provided

Test plan

  • npx vitest run packages/better-auth/src/plugins/admin/admin.test.ts — 71/71 tests pass
  • npx tsc --noEmit in packages/better-auth — clean

Fixes #7837


Summary by cubic

Fixes filtering in the admin listUsers route to accept falsy filter values (false, 0, ""). This allows filters like banned=false and role=0 to work.

  • Bug Fixes
    • Changed filter check to use filterValue !== undefined.
    • Added tests for false and 0 values.
    • Confirmed default filterField falls back to email.

Written for commit 96af62814e. Summary will update on new commits.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/better-auth/better-auth/pull/7899 **Author:** [@jayy-77](https://github.com/jayy-77) **Created:** 2/10/2026 **Status:** ❌ Closed **Base:** `canary` ← **Head:** `fix/admin-listusers-falsy-filter-7837` --- ### 📝 Commits (1) - [`96af628`](https://github.com/better-auth/better-auth/commit/96af62814e2b973c8a3d66a45b53994132c2019d) fix(admin): handle falsy filter values in listUsers ### 📊 Changes **2 files changed** (+60 additions, -1 deletions) <details> <summary>View changed files</summary> 📝 `packages/better-auth/src/plugins/admin/admin.test.ts` (+59 -0) 📝 `packages/better-auth/src/plugins/admin/routes.ts` (+1 -1) </details> ### 📄 Description ## Problem The `listUsers` admin route uses a truthy check (`if (ctx.query?.filterValue)`) to decide whether to apply a filter. This silently drops valid falsy values like `false`, `0`, and empty string `""`, making it impossible to filter by e.g. `banned = false`. ## Changes - Changed the condition from `if (ctx.query?.filterValue)` to `if (ctx.query?.filterValue !== undefined)` so falsy values are correctly passed through to the query builder. - Added edge-case tests for: - Filtering by boolean `false` (`banned = false`) - Filtering by numeric `0` - Default `filterField` fallback when not provided ## Test plan - `npx vitest run packages/better-auth/src/plugins/admin/admin.test.ts` — 71/71 tests pass - `npx tsc --noEmit` in `packages/better-auth` — clean Fixes #7837 <!-- This is an auto-generated description by cubic. --> --- ## Summary by cubic Fixes filtering in the admin listUsers route to accept falsy filter values (false, 0, ""). This allows filters like banned=false and role=0 to work. - **Bug Fixes** - Changed filter check to use filterValue !== undefined. - Added tests for false and 0 values. - Confirmed default filterField falls back to email. <sup>Written for commit 96af62814e2b973c8a3d66a45b53994132c2019d. Summary will update on new commits.</sup> <!-- End of auto-generated description by cubic. --> --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
GiteaMirror added the pull-request label 2026-03-13 13:43:18 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/better-auth#7620