[GH-ISSUE #5767] http://localhost:3000/api/auth/reference#tag/admin/get/admin/list-users 模糊查询bug #18974

Closed
opened 2026-04-15 17:42:56 -05:00 by GiteaMirror · 17 comments
Owner

Originally created by @Rvvvv1 on GitHub (Nov 5, 2025).
Original GitHub issue: https://github.com/better-auth/better-auth/issues/5767

Is this suited for github?

  • Yes, this is suited for github

To Reproduce

admin插件引入 当我想列出用户数据时发现 请求在不输入过滤字段时情况下可以模糊查询 ,但是如果需要过滤字段 如role eq admin 就只能输入准确的name或email才能查出到用户
Admin Plugin Introduction
When I attempted to list user data, I discovered that the request could perform fuzzy searches without entering filter fields. However, if a filter field such as "role eq admin" is required, only by entering the exact name or email can a user be retrieved

for example :
1.Do not filter fields, only search

Image


2.Search and filter for incomplete field name input

Image


3.Search and filter field names. If entered completely, it is normal

Image

database is postgresql

Current vs. Expected behavior

Image

What version of Better Auth are you using?

1.3.29

System info

1

Which area(s) are affected? (Select all that apply)

Backend, Client

Auth config (if applicable)

import { betterAuth } from "better-auth"
export const auth = betterAuth({
  emailAndPassword: {  
    enabled: true
  },
});

Additional context

No response

Originally created by @Rvvvv1 on GitHub (Nov 5, 2025). Original GitHub issue: https://github.com/better-auth/better-auth/issues/5767 ### Is this suited for github? - [ ] Yes, this is suited for github ### To Reproduce admin插件引入 当我想列出用户数据时发现 请求在不输入过滤字段时情况下可以模糊查询 ,但是如果需要过滤字段 如role eq admin 就只能输入准确的name或email才能查出到用户 Admin Plugin Introduction When I attempted to list user data, I discovered that the request could perform fuzzy searches without entering filter fields. However, if a filter field such as "role eq admin" is required, only by entering the exact name or email can a user be retrieved for example : 1.Do not filter fields, only search <img width="2982" height="1790" alt="Image" src="https://github.com/user-attachments/assets/838ea263-95ac-4d06-97c6-380ae2dcce4e" />  2.Search and filter for incomplete field name input <img width="2974" height="1658" alt="Image" src="https://github.com/user-attachments/assets/24e3ba8d-c770-4994-a8b8-839af090b096" />  3.Search and filter field names. If entered completely, it is normal <img width="2948" height="1624" alt="Image" src="https://github.com/user-attachments/assets/5ce345d6-aced-4971-befc-ae1332267a16" /> database is postgresql ### Current vs. Expected behavior <img width="850" height="388" alt="Image" src="https://github.com/user-attachments/assets/0da2960c-99c0-413d-901a-006ff6d4e21e" /> ### What version of Better Auth are you using? 1.3.29 ### System info ```bash 1 ``` ### Which area(s) are affected? (Select all that apply) Backend, Client ### Auth config (if applicable) ```typescript import { betterAuth } from "better-auth" export const auth = betterAuth({ emailAndPassword: { enabled: true }, }); ``` ### Additional context _No response_
GiteaMirror added the lockedbug labels 2026-04-15 17:42:56 -05:00
Author
Owner

@dosubot[bot] commented on GitHub (Nov 5, 2025):

你的问题是已知 bug,已经在 GitHub 上被确认并修复(见 issue #5295)。具体表现为:只做模糊查询时没问题,但加上过滤字段(如 role eq admin)后,模糊查询就失效,只能精确匹配。

这个 bug 已在后续版本修复(相关 PR:#5299),但你的 1.3.29 版本尚未包含该修复。建议升级到更高版本(如 5311 及以上),即可正常支持“过滤+模糊查询”组合。

这个问题非常适合在 GitHub 进行跟踪和反馈。如果暂时无法升级,可以考虑只用单一查询条件作为临时 workaround,但推荐升级以获得完整功能。

To reply, just mention @dosu.


How did I do? Good | Irrelevant | Incorrect | Verbose | Hallucination | Report 🐛 | Other  Chat with Dosu Join Discord Share on X

<!-- gh-comment-id:3489002028 --> @dosubot[bot] commented on GitHub (Nov 5, 2025): <!-- Answer --> 你的问题是已知 bug,已经在 GitHub 上被确认并修复(见 [issue #5295](https://github.com/better-auth/better-auth/issues/5295))。具体表现为:只做模糊查询时没问题,但加上过滤字段(如 role eq admin)后,模糊查询就失效,只能精确匹配。 这个 bug 已在后续版本修复(相关 PR:[#5299](https://github.com/better-auth/better-auth/pull/5299)),但你的 1.3.29 版本尚未包含该修复。建议升级到更高版本(如 5311 及以上),即可正常支持“过滤+模糊查询”组合。 这个问题非常适合在 GitHub 进行跟踪和反馈。如果暂时无法升级,可以考虑只用单一查询条件作为临时 workaround,但推荐升级以获得完整功能。 <!-- Dosu Comment Footer --> *To reply, just mention [@dosu](https://go.dosu.dev/dosubot).* --- <sup>How did I do? [Good](https://app.dosu.dev/response-feedback/ba21491c-3ae3-43fe-b39d-99bad34e5c91?feedback_type=great_response) | [Irrelevant](https://app.dosu.dev/response-feedback/ba21491c-3ae3-43fe-b39d-99bad34e5c91?feedback_type=irrelevant_answer) | [Incorrect](https://app.dosu.dev/response-feedback/ba21491c-3ae3-43fe-b39d-99bad34e5c91?feedback_type=incorrect_sources) | [Verbose](https://app.dosu.dev/response-feedback/ba21491c-3ae3-43fe-b39d-99bad34e5c91?feedback_type=too_verbose) | [Hallucination](https://app.dosu.dev/response-feedback/ba21491c-3ae3-43fe-b39d-99bad34e5c91?feedback_type=hallucination) | [Report 🐛](https://app.dosu.dev/response-feedback/ba21491c-3ae3-43fe-b39d-99bad34e5c91?feedback_type=bug_report) | [Other](https://app.dosu.dev/response-feedback/ba21491c-3ae3-43fe-b39d-99bad34e5c91?feedback_type=other)</sup>&nbsp;&nbsp;[![Chat with Dosu](https://dosu.dev/dosu-chat-badge.svg)](https://app.dosu.dev/cdda13d9-dd27-4d31-b09a-5d8bec92de21/ask?utm_source=github)&nbsp;[![Join Discord](https://img.shields.io/badge/join-5865F2?logo=discord&logoColor=white&label=)](https://go.dosu.dev/discord-bot)&nbsp;[![Share on X](https://img.shields.io/badge/X-share-black)](https://twitter.com/intent/tweet?text=%40dosu_ai%20helped%20me%20solve%20this%20issue!&url=https%3A//github.com/better-auth/better-auth/issues/5767)
Author
Owner

@Rvvvv1 commented on GitHub (Nov 5, 2025):

@dosu

Image I have upgraded to "better-auth": "^1.3.34", Now it's a direct failure

<!-- gh-comment-id:3489065426 --> @Rvvvv1 commented on GitHub (Nov 5, 2025): @dosu <img width="2912" height="1582" alt="Image" src="https://github.com/user-attachments/assets/35394395-c566-43d1-8f10-9a2ca4f89553" /> I have upgraded to "better-auth": "^1.3.34", Now it's a direct failure
Author
Owner

@dosubot[bot] commented on GitHub (Nov 5, 2025):

你的 400 VALIDATION_ERROR 是因为 1.3.34 版本后,/api/auth/admin/list-users 的参数格式有了重大变更:所有查询参数(如 search、filter、sort、limit 等)都必须包裹在 query 对象里,不能再作为顶层参数传递,否则会直接报参数校验错误。

正确的请求格式应该是:

await authClient.admin.listUsers({
  query: {
    searchValue: "Rvvvv",
    searchField: "name",
    searchOperator: "contains",
    filterField: "role",
    filterOperator: "eq",
    filterValue: "admin",
    sortBy: "createdAt",
    sortDirection: "desc",
    limit: 10,
    offset: 0,
  }
})

如果你是直接用 HTTP 请求,query string 需要这样嵌套(以 URLSearchParams 方式编码):

/api/auth/admin/list-users?query[searchValue]=Rvvvv&query[searchField]=name&query[searchOperator]=contains&query[filterField]=role&query[filterOperator]=eq&query[filterValue]=admin&query[sortBy]=createdAt&query[sortDirection]=desc&query[limit]=10&query[offset]=0

详细变更说明见 PR:#4119
组合模糊搜索和过滤的用法见 PR:#5299

只要把所有参数都放到 query 里即可恢复正常。

To reply, just mention @dosu.


How did I do? Good | Irrelevant | Incorrect | Verbose | Hallucination | Report 🐛 | Other  Chat with Dosu Join Discord Share on X

<!-- gh-comment-id:3489071596 --> @dosubot[bot] commented on GitHub (Nov 5, 2025): <!-- Answer --> 你的 400 VALIDATION_ERROR 是因为 1.3.34 版本后,/api/auth/admin/list-users 的参数格式有了重大变更:所有查询参数(如 search、filter、sort、limit 等)都必须包裹在 query 对象里,不能再作为顶层参数传递,否则会直接报参数校验错误。 正确的请求格式应该是: ```js await authClient.admin.listUsers({ query: { searchValue: "Rvvvv", searchField: "name", searchOperator: "contains", filterField: "role", filterOperator: "eq", filterValue: "admin", sortBy: "createdAt", sortDirection: "desc", limit: 10, offset: 0, } }) ``` 如果你是直接用 HTTP 请求,query string 需要这样嵌套(以 URLSearchParams 方式编码): ``` /api/auth/admin/list-users?query[searchValue]=Rvvvv&query[searchField]=name&query[searchOperator]=contains&query[filterField]=role&query[filterOperator]=eq&query[filterValue]=admin&query[sortBy]=createdAt&query[sortDirection]=desc&query[limit]=10&query[offset]=0 ``` 详细变更说明见 PR:[#4119](https://github.com/better-auth/better-auth/pull/4119) 组合模糊搜索和过滤的用法见 PR:[#5299](https://github.com/better-auth/better-auth/pull/5299) 只要把所有参数都放到 query 里即可恢复正常。 <!-- Dosu Comment Footer --> *To reply, just mention [@dosu](https://go.dosu.dev/dosubot).* --- <sup>How did I do? [Good](https://app.dosu.dev/response-feedback/a85ddc4a-a3c5-45f8-8835-38c3e6ef6938?feedback_type=great_response) | [Irrelevant](https://app.dosu.dev/response-feedback/a85ddc4a-a3c5-45f8-8835-38c3e6ef6938?feedback_type=irrelevant_answer) | [Incorrect](https://app.dosu.dev/response-feedback/a85ddc4a-a3c5-45f8-8835-38c3e6ef6938?feedback_type=incorrect_sources) | [Verbose](https://app.dosu.dev/response-feedback/a85ddc4a-a3c5-45f8-8835-38c3e6ef6938?feedback_type=too_verbose) | [Hallucination](https://app.dosu.dev/response-feedback/a85ddc4a-a3c5-45f8-8835-38c3e6ef6938?feedback_type=hallucination) | [Report 🐛](https://app.dosu.dev/response-feedback/a85ddc4a-a3c5-45f8-8835-38c3e6ef6938?feedback_type=bug_report) | [Other](https://app.dosu.dev/response-feedback/a85ddc4a-a3c5-45f8-8835-38c3e6ef6938?feedback_type=other)</sup>&nbsp;&nbsp;[![Chat with Dosu](https://dosu.dev/dosu-chat-badge.svg)](https://app.dosu.dev/cdda13d9-dd27-4d31-b09a-5d8bec92de21/ask?utm_source=github)&nbsp;[![Join Discord](https://img.shields.io/badge/join-5865F2?logo=discord&logoColor=white&label=)](https://go.dosu.dev/discord-bot)&nbsp;[![Share on X](https://img.shields.io/badge/X-share-black)](https://twitter.com/intent/tweet?text=%40dosu_ai%20helped%20me%20solve%20this%20issue!&url=https%3A//github.com/better-auth/better-auth/issues/5767)
Author
Owner

@Rvvvv1 commented on GitHub (Nov 6, 2025):

@dosu 还是不行 我按照你的写法

Image 去请求发现 searchOperator: "contains",
filterField: "role",
filterOperator: "eq", 不带这几个参数可以搜索出来 带上了就返回不到数据

Image Image
<!-- gh-comment-id:3494575456 --> @Rvvvv1 commented on GitHub (Nov 6, 2025): @dosu 还是不行 我按照你的写法 <img width="392" height="136" alt="Image" src="https://github.com/user-attachments/assets/b263a0a9-7056-4344-8f48-8df925746f4f" /> 去请求发现 searchOperator: "contains", filterField: "role", filterOperator: "eq", 不带这几个参数可以搜索出来 带上了就返回不到数据 <img width="2206" height="1128" alt="Image" src="https://github.com/user-attachments/assets/db84bf3d-395a-480b-86ec-4f24cb33885c" /> <img width="848" height="248" alt="Image" src="https://github.com/user-attachments/assets/2d5532c3-457e-4efe-ae8f-c8749d3644ef" />
Author
Owner

@Rvvvv1 commented on GitHub (Nov 6, 2025):

@dosu

Image
<!-- gh-comment-id:3494576398 --> @Rvvvv1 commented on GitHub (Nov 6, 2025): @dosu <img width="1164" height="1300" alt="Image" src="https://github.com/user-attachments/assets/6dc369f0-a10f-4fb2-b048-2a4585ea8d6b" />
Author
Owner

@dosubot[bot] commented on GitHub (Nov 6, 2025):

你的查询代码结构是正确的,后端逻辑也支持“模糊搜索 + 角色过滤”组合(AND 关系),不会屏蔽这种用法。如果结果为空,通常是因为数据库里没有同时满足 name 包含 "Rvvvv" 且 role 等于 "admin" 的用户,而不是 API 或代码 bug。你可以:

  1. 分别只用 search 或 filter 查询,确认各自能查到数据;
  2. 检查 name 字段是否完全匹配(比如大小写、空格、特殊字符);
  3. 检查 role 字段是否确实为 "admin"(注意有些用户 role 可能是数组或有多个角色,filterOperator: "eq" 只匹配完全等于 "admin" 的用户,如果是 ["user", "admin"] 这种结构,需要用 filterOperator: "contains");
  4. 如果还是不行,可以开启 SQL 日志,确认实际执行的 SQL 语句和数据情况。

相关实现和限制可以参考 源码issue #5295。如果你的用户数据结构有多角色,建议尝试 filterOperator: "contains"。

To reply, just mention @dosu.


How did I do? Good | Irrelevant | Incorrect | Verbose | Hallucination | Report 🐛 | Other  Chat with Dosu Join Discord Share on X

<!-- gh-comment-id:3494582319 --> @dosubot[bot] commented on GitHub (Nov 6, 2025): <!-- Answer --> 你的查询代码结构是正确的,后端逻辑也支持“模糊搜索 + 角色过滤”组合(AND 关系),不会屏蔽这种用法。如果结果为空,通常是因为数据库里没有同时满足 name 包含 "Rvvvv" 且 role 等于 "admin" 的用户,而不是 API 或代码 bug。你可以: 1. 分别只用 search 或 filter 查询,确认各自能查到数据; 2. 检查 name 字段是否完全匹配(比如大小写、空格、特殊字符); 3. 检查 role 字段是否确实为 "admin"(注意有些用户 role 可能是数组或有多个角色,filterOperator: "eq" 只匹配完全等于 "admin" 的用户,如果是 ["user", "admin"] 这种结构,需要用 filterOperator: "contains"); 4. 如果还是不行,可以开启 SQL 日志,确认实际执行的 SQL 语句和数据情况。 相关实现和限制可以参考 [源码](https://github.com/better-auth/better-auth/blob/7e6106707539ec9a8510c02cc84ac2e9c2d88db0/packages/better-auth/src/plugins/admin/admin.ts#L599-L763) 和 [issue #5295](https://github.com/better-auth/better-auth/issues/5295)。如果你的用户数据结构有多角色,建议尝试 filterOperator: "contains"。 <!-- Dosu Comment Footer --> *To reply, just mention [@dosu](https://go.dosu.dev/dosubot).* --- <sup>How did I do? [Good](https://app.dosu.dev/response-feedback/cbc7fcc5-d2ea-40c6-bff5-9f56e7c0a391?feedback_type=great_response) | [Irrelevant](https://app.dosu.dev/response-feedback/cbc7fcc5-d2ea-40c6-bff5-9f56e7c0a391?feedback_type=irrelevant_answer) | [Incorrect](https://app.dosu.dev/response-feedback/cbc7fcc5-d2ea-40c6-bff5-9f56e7c0a391?feedback_type=incorrect_sources) | [Verbose](https://app.dosu.dev/response-feedback/cbc7fcc5-d2ea-40c6-bff5-9f56e7c0a391?feedback_type=too_verbose) | [Hallucination](https://app.dosu.dev/response-feedback/cbc7fcc5-d2ea-40c6-bff5-9f56e7c0a391?feedback_type=hallucination) | [Report 🐛](https://app.dosu.dev/response-feedback/cbc7fcc5-d2ea-40c6-bff5-9f56e7c0a391?feedback_type=bug_report) | [Other](https://app.dosu.dev/response-feedback/cbc7fcc5-d2ea-40c6-bff5-9f56e7c0a391?feedback_type=other)</sup>&nbsp;&nbsp;[![Chat with Dosu](https://dosu.dev/dosu-chat-badge.svg)](https://app.dosu.dev/cdda13d9-dd27-4d31-b09a-5d8bec92de21/ask?utm_source=github)&nbsp;[![Join Discord](https://img.shields.io/badge/join-5865F2?logo=discord&logoColor=white&label=)](https://go.dosu.dev/discord-bot)&nbsp;[![Share on X](https://img.shields.io/badge/X-share-black)](https://twitter.com/intent/tweet?text=%40dosu_ai%20helped%20me%20solve%20this%20issue!&url=https%3A//github.com/better-auth/better-auth/issues/5767)
Author
Owner

@Rvvvv1 commented on GitHub (Nov 6, 2025):

@dosu 我的数据库中 有符合这样的角色 当我不使用 filterField: "role",
filterOperator: "eq",
filterValue: "admin", 可以搜索到数据

Image

Image 返回的数据中 有admin 字符串

<!-- gh-comment-id:3494589536 --> @Rvvvv1 commented on GitHub (Nov 6, 2025): @dosu 我的数据库中 有符合这样的角色 当我不使用 filterField: "role", filterOperator: "eq", filterValue: "admin", 可以搜索到数据 <img width="1006" height="904" alt="Image" src="https://github.com/user-attachments/assets/8f630058-72fb-4ece-ab55-888f2f171f9c" /> <img width="2694" height="1462" alt="Image" src="https://github.com/user-attachments/assets/c44fb599-792d-4cf5-b5b2-04acfee6ea7e" /> 返回的数据中 有admin 字符串
Author
Owner

@Rvvvv1 commented on GitHub (Nov 6, 2025):

@dosu

<!-- gh-comment-id:3494590076 --> @Rvvvv1 commented on GitHub (Nov 6, 2025): @dosu
Author
Owner

@dosubot[bot] commented on GitHub (Nov 6, 2025):

你的问题和 PostgreSQL/Drizzle 适配器的已知 bug 有关:在 1.3.29 ~ 1.3.34 版本,模糊搜索(如 name contains "Rvvvv")和角色过滤(role eq "admin")组合时,API 实际不会返回任何数据,即使数据库里有符合条件的用户。这是底层 SQL 组合条件处理的 bug,已在 5311 版本修复(见 #5295PR #5299)。

建议你升级到 5311 或以上版本,组合查询会恢复正常。如果你的 user 表 role 字段是字符串(如 "admin"),用 filterOperator: "eq";如果是数组或 JSONB,建议用 filterOperator: "contains"。

升级后,查询格式如下:

await authClient.admin.listUsers({
  query: {
    searchValue: "Rvvvv",
    searchField: "name",
    searchOperator: "contains",
    filterField: "role",
    filterOperator: "eq", // 或 "contains"(如果 role 是数组/JSONB)
    filterValue: "admin",
    limit: 10,
    offset: 0,
  }
})

如果暂时无法升级,可以只用 search 查询,前端自行过滤 role 字段。升级后如还有问题,请确认 role 字段类型和数据内容。

To reply, just mention @dosu.


How did I do? Good | Irrelevant | Incorrect | Verbose | Hallucination | Report 🐛 | Other  Chat with Dosu Join Discord Share on X

<!-- gh-comment-id:3494599535 --> @dosubot[bot] commented on GitHub (Nov 6, 2025): <!-- Answer --> 你的问题和 PostgreSQL/Drizzle 适配器的已知 bug 有关:在 1.3.29 ~ 1.3.34 版本,模糊搜索(如 name contains "Rvvvv")和角色过滤(role eq "admin")组合时,API 实际不会返回任何数据,即使数据库里有符合条件的用户。这是底层 SQL 组合条件处理的 bug,已在 5311 版本修复(见 [#5295](https://github.com/better-auth/better-auth/issues/5295) 和 [PR #5299](https://github.com/better-auth/better-auth/pull/5299))。 建议你升级到 5311 或以上版本,组合查询会恢复正常。如果你的 user 表 role 字段是字符串(如 "admin"),用 filterOperator: "eq";如果是数组或 JSONB,建议用 filterOperator: "contains"。 升级后,查询格式如下: ```js await authClient.admin.listUsers({ query: { searchValue: "Rvvvv", searchField: "name", searchOperator: "contains", filterField: "role", filterOperator: "eq", // 或 "contains"(如果 role 是数组/JSONB) filterValue: "admin", limit: 10, offset: 0, } }) ``` 如果暂时无法升级,可以只用 search 查询,前端自行过滤 role 字段。升级后如还有问题,请确认 role 字段类型和数据内容。 <!-- Dosu Comment Footer --> *To reply, just mention [@dosu](https://go.dosu.dev/dosubot).* --- <sup>How did I do? [Good](https://app.dosu.dev/response-feedback/03078701-f6a7-47de-a1a0-201cba704328?feedback_type=great_response) | [Irrelevant](https://app.dosu.dev/response-feedback/03078701-f6a7-47de-a1a0-201cba704328?feedback_type=irrelevant_answer) | [Incorrect](https://app.dosu.dev/response-feedback/03078701-f6a7-47de-a1a0-201cba704328?feedback_type=incorrect_sources) | [Verbose](https://app.dosu.dev/response-feedback/03078701-f6a7-47de-a1a0-201cba704328?feedback_type=too_verbose) | [Hallucination](https://app.dosu.dev/response-feedback/03078701-f6a7-47de-a1a0-201cba704328?feedback_type=hallucination) | [Report 🐛](https://app.dosu.dev/response-feedback/03078701-f6a7-47de-a1a0-201cba704328?feedback_type=bug_report) | [Other](https://app.dosu.dev/response-feedback/03078701-f6a7-47de-a1a0-201cba704328?feedback_type=other)</sup>&nbsp;&nbsp;[![Chat with Dosu](https://dosu.dev/dosu-chat-badge.svg)](https://app.dosu.dev/cdda13d9-dd27-4d31-b09a-5d8bec92de21/ask?utm_source=github)&nbsp;[![Join Discord](https://img.shields.io/badge/join-5865F2?logo=discord&logoColor=white&label=)](https://go.dosu.dev/discord-bot)&nbsp;[![Share on X](https://img.shields.io/badge/X-share-black)](https://twitter.com/intent/tweet?text=%40dosu_ai%20helped%20me%20solve%20this%20issue!&url=https%3A//github.com/better-auth/better-auth/issues/5767)
Author
Owner

@Rvvvv1 commented on GitHub (Nov 6, 2025):

@dosu 我已经安装了新的版本 bettauth-auth 1.3.34版本 但还是不行

<!-- gh-comment-id:3494616568 --> @Rvvvv1 commented on GitHub (Nov 6, 2025): @dosu 我已经安装了新的版本 bettauth-auth 1.3.34版本 但还是不行
Author
Owner

@dosubot[bot] commented on GitHub (Nov 6, 2025):

你遇到的“模糊搜索 + 角色过滤”组合查询无结果,是 1.3.29 ~ 1.3.34 版本 PostgreSQL/Drizzle 适配器的已知 bug,1.3.34 也没有修复。这个问题在 5311 及以上版本才彻底修复(见 PR #5299,合并于 2025-10-14)——1.3.34 版本升级后依然会遇到这个问题是正常的,和用法无关,确实是底层 bug。

解决方法:升级到 5311 或更高版本即可恢复“模糊搜索 + 过滤”组合查询的正常功能,升级后无需更改用法,原有查询格式即可生效。参考

如果暂时无法升级,可以只用 search 查询,前端自行过滤 role 字段,作为临时方案。

如需升级帮助或遇到新问题可以随时 @dosu。

To reply, just mention @dosu.


How did I do? Good | Irrelevant | Incorrect | Verbose | Hallucination | Report 🐛 | Other  Chat with Dosu Join Discord Share on X

<!-- gh-comment-id:3494626589 --> @dosubot[bot] commented on GitHub (Nov 6, 2025): <!-- Answer --> 你遇到的“模糊搜索 + 角色过滤”组合查询无结果,是 1.3.29 ~ 1.3.34 版本 PostgreSQL/Drizzle 适配器的已知 bug,1.3.34 也没有修复。这个问题在 5311 及以上版本才彻底修复(见 PR #5299,合并于 2025-10-14)——1.3.34 版本升级后依然会遇到这个问题是正常的,和用法无关,确实是底层 bug。 解决方法:升级到 5311 或更高版本即可恢复“模糊搜索 + 过滤”组合查询的正常功能,升级后无需更改用法,原有查询格式即可生效。[参考](https://github.com/better-auth/better-auth/pull/5299) 如果暂时无法升级,可以只用 search 查询,前端自行过滤 role 字段,作为临时方案。 如需升级帮助或遇到新问题可以随时 @dosu。 <!-- Dosu Comment Footer --> *To reply, just mention [@dosu](https://go.dosu.dev/dosubot).* --- <sup>How did I do? [Good](https://app.dosu.dev/response-feedback/1f902356-e0b0-4bdd-91fa-b34c814390da?feedback_type=great_response) | [Irrelevant](https://app.dosu.dev/response-feedback/1f902356-e0b0-4bdd-91fa-b34c814390da?feedback_type=irrelevant_answer) | [Incorrect](https://app.dosu.dev/response-feedback/1f902356-e0b0-4bdd-91fa-b34c814390da?feedback_type=incorrect_sources) | [Verbose](https://app.dosu.dev/response-feedback/1f902356-e0b0-4bdd-91fa-b34c814390da?feedback_type=too_verbose) | [Hallucination](https://app.dosu.dev/response-feedback/1f902356-e0b0-4bdd-91fa-b34c814390da?feedback_type=hallucination) | [Report 🐛](https://app.dosu.dev/response-feedback/1f902356-e0b0-4bdd-91fa-b34c814390da?feedback_type=bug_report) | [Other](https://app.dosu.dev/response-feedback/1f902356-e0b0-4bdd-91fa-b34c814390da?feedback_type=other)</sup>&nbsp;&nbsp;[![Chat with Dosu](https://dosu.dev/dosu-chat-badge.svg)](https://app.dosu.dev/cdda13d9-dd27-4d31-b09a-5d8bec92de21/ask?utm_source=github)&nbsp;[![Join Discord](https://img.shields.io/badge/join-5865F2?logo=discord&logoColor=white&label=)](https://go.dosu.dev/discord-bot)&nbsp;[![Share on X](https://img.shields.io/badge/X-share-black)](https://twitter.com/intent/tweet?text=%40dosu_ai%20helped%20me%20solve%20this%20issue!&url=https%3A//github.com/better-auth/better-auth/issues/5767)
Author
Owner

@Rvvvv1 commented on GitHub (Nov 6, 2025):

@dosu "drizzle-orm": "^0.44.6", "better-auth": "^1.3.34", 这是我的版本 已经按要求升级了 但是模糊查询上过滤查找 还是会有BUG

<!-- gh-comment-id:3494704935 --> @Rvvvv1 commented on GitHub (Nov 6, 2025): @dosu "drizzle-orm": "^0.44.6", "better-auth": "^1.3.34", 这是我的版本 已经按要求升级了 但是模糊查询➕上过滤查找 还是会有BUG
Author
Owner

@dosubot[bot] commented on GitHub (Nov 6, 2025):

你升级到 1.3.34 后,模糊查询 + 过滤(如 role eq admin)的问题依然存在,是因为这个 bug 只在更高版本(build 5311 及以上)才彻底修复。1.3.34 还没有包含这个修复,升级到 5311 或更高版本后才会正常返回符合条件的数据(无需额外配置或迁移步骤,只需升级版本即可)相关说明

临时解决方案:只能用 search 查询,前端自行过滤 role 字段。
根本解决方案:升级到 5311 或更高版本,原有查询格式即可生效,模糊搜索和过滤可以组合使用。

如需升级帮助或遇到新问题可以随时 @dosu。

To reply, just mention @dosu.


How did I do? Good | Irrelevant | Incorrect | Verbose | Hallucination | Report 🐛 | Other  Chat with Dosu Join Discord Share on X

<!-- gh-comment-id:3494721645 --> @dosubot[bot] commented on GitHub (Nov 6, 2025): <!-- Answer --> 你升级到 1.3.34 后,模糊查询 + 过滤(如 role eq admin)的问题依然存在,是因为这个 bug 只在更高版本(build 5311 及以上)才彻底修复。1.3.34 还没有包含这个修复,升级到 5311 或更高版本后才会正常返回符合条件的数据(无需额外配置或迁移步骤,只需升级版本即可)[相关说明](https://github.com/better-auth/better-auth/issues/5295)。 临时解决方案:只能用 search 查询,前端自行过滤 role 字段。 根本解决方案:升级到 5311 或更高版本,原有查询格式即可生效,模糊搜索和过滤可以组合使用。 如需升级帮助或遇到新问题可以随时 @dosu。 <!-- Dosu Comment Footer --> *To reply, just mention [@dosu](https://go.dosu.dev/dosubot).* --- <sup>How did I do? [Good](https://app.dosu.dev/response-feedback/bf741fd6-cfb7-47c1-84c9-47fea9f1ef3e?feedback_type=great_response) | [Irrelevant](https://app.dosu.dev/response-feedback/bf741fd6-cfb7-47c1-84c9-47fea9f1ef3e?feedback_type=irrelevant_answer) | [Incorrect](https://app.dosu.dev/response-feedback/bf741fd6-cfb7-47c1-84c9-47fea9f1ef3e?feedback_type=incorrect_sources) | [Verbose](https://app.dosu.dev/response-feedback/bf741fd6-cfb7-47c1-84c9-47fea9f1ef3e?feedback_type=too_verbose) | [Hallucination](https://app.dosu.dev/response-feedback/bf741fd6-cfb7-47c1-84c9-47fea9f1ef3e?feedback_type=hallucination) | [Report 🐛](https://app.dosu.dev/response-feedback/bf741fd6-cfb7-47c1-84c9-47fea9f1ef3e?feedback_type=bug_report) | [Other](https://app.dosu.dev/response-feedback/bf741fd6-cfb7-47c1-84c9-47fea9f1ef3e?feedback_type=other)</sup>&nbsp;&nbsp;[![Chat with Dosu](https://dosu.dev/dosu-chat-badge.svg)](https://app.dosu.dev/cdda13d9-dd27-4d31-b09a-5d8bec92de21/ask?utm_source=github)&nbsp;[![Join Discord](https://img.shields.io/badge/join-5865F2?logo=discord&logoColor=white&label=)](https://go.dosu.dev/discord-bot)&nbsp;[![Share on X](https://img.shields.io/badge/X-share-black)](https://twitter.com/intent/tweet?text=%40dosu_ai%20helped%20me%20solve%20this%20issue!&url=https%3A//github.com/better-auth/better-auth/issues/5767)
Author
Owner

@Rvvvv1 commented on GitHub (Nov 6, 2025):

@dosu 如何升级到5311版本 我使用的是bun

<!-- gh-comment-id:3494724197 --> @Rvvvv1 commented on GitHub (Nov 6, 2025): @dosu 如何升级到5311版本 我使用的是bun
Author
Owner

@dosubot[bot] commented on GitHub (Nov 6, 2025):

目前 npm 上最新的正式版 better-auth 是 1.3.34,没有直接叫“5311”的版本号。所谓“build 5311”其实是内部构建号或 CI 编号,不是 npm 的标准 semver 版本。修复模糊查询+过滤 bug 的代码只会在后续新版本(比如 1.4.x beta 或更高)才会发布。

升级方法如下:

  1. 检查 npm 是否有 beta/nightly/canary 版本(比如 1.4.0-beta.1):

    bun add better-auth@beta
    

    bun add better-auth@next
    

    如果没有 beta/next/canary 版本,可以关注 npm 或 GitHub 发布页,等新版本发布。

  2. 如果你需要安装某个 GitHub commit(比如 5311 修复 PR 合并后的 commit),可以用 Bun 直接安装 GitHub 源码:

    bun add better-auth@github:better-auth/better-auth#<commit-hash>
    

    其中 <commit-hash> 替换为 5311 修复 PR 合并后的 commit id。

  3. 如果只需要稳定版,建议等 1.4.x 或更高正式版发布后再升级。

目前 1.3.34 没有修复该 bug,只有 beta/nightly 或未来正式版才有修复。升级后无需额外配置,原有查询格式即可生效。

如需查找最新 beta/nightly 版本,可以在 npm 或 GitHub Releases 搜索 better-auth@betabetter-auth@next

To reply, just mention @dosu.


How did I do? Good | Irrelevant | Incorrect | Verbose | Hallucination | Report 🐛 | Other  Chat with Dosu Join Discord Share on X

<!-- gh-comment-id:3494738170 --> @dosubot[bot] commented on GitHub (Nov 6, 2025): <!-- Answer --> 目前 npm 上最新的正式版 better-auth 是 1.3.34,没有直接叫“5311”的版本号。所谓“build 5311”其实是内部构建号或 CI 编号,不是 npm 的标准 semver 版本。修复模糊查询+过滤 bug 的代码只会在后续新版本(比如 1.4.x beta 或更高)才会发布。 升级方法如下: 1. 检查 npm 是否有 beta/nightly/canary 版本(比如 1.4.0-beta.1): ```bash bun add better-auth@beta ``` 或 ```bash bun add better-auth@next ``` 如果没有 beta/next/canary 版本,可以关注 npm 或 GitHub 发布页,等新版本发布。 2. 如果你需要安装某个 GitHub commit(比如 5311 修复 PR 合并后的 commit),可以用 Bun 直接安装 GitHub 源码: ```bash bun add better-auth@github:better-auth/better-auth#<commit-hash> ``` 其中 `<commit-hash>` 替换为 5311 修复 PR 合并后的 commit id。 3. 如果只需要稳定版,建议等 1.4.x 或更高正式版发布后再升级。 目前 1.3.34 没有修复该 bug,只有 beta/nightly 或未来正式版才有修复。升级后无需额外配置,原有查询格式即可生效。 如需查找最新 beta/nightly 版本,可以在 npm 或 GitHub Releases 搜索 `better-auth@beta` 或 `better-auth@next`。 <!-- Dosu Comment Footer --> *To reply, just mention [@dosu](https://go.dosu.dev/dosubot).* --- <sup>How did I do? [Good](https://app.dosu.dev/response-feedback/4d7f3bc2-6971-4d9c-bdae-a77fe6e0cb4c?feedback_type=great_response) | [Irrelevant](https://app.dosu.dev/response-feedback/4d7f3bc2-6971-4d9c-bdae-a77fe6e0cb4c?feedback_type=irrelevant_answer) | [Incorrect](https://app.dosu.dev/response-feedback/4d7f3bc2-6971-4d9c-bdae-a77fe6e0cb4c?feedback_type=incorrect_sources) | [Verbose](https://app.dosu.dev/response-feedback/4d7f3bc2-6971-4d9c-bdae-a77fe6e0cb4c?feedback_type=too_verbose) | [Hallucination](https://app.dosu.dev/response-feedback/4d7f3bc2-6971-4d9c-bdae-a77fe6e0cb4c?feedback_type=hallucination) | [Report 🐛](https://app.dosu.dev/response-feedback/4d7f3bc2-6971-4d9c-bdae-a77fe6e0cb4c?feedback_type=bug_report) | [Other](https://app.dosu.dev/response-feedback/4d7f3bc2-6971-4d9c-bdae-a77fe6e0cb4c?feedback_type=other)</sup>&nbsp;&nbsp;[![Chat with Dosu](https://dosu.dev/dosu-chat-badge.svg)](https://app.dosu.dev/cdda13d9-dd27-4d31-b09a-5d8bec92de21/ask?utm_source=github)&nbsp;[![Join Discord](https://img.shields.io/badge/join-5865F2?logo=discord&logoColor=white&label=)](https://go.dosu.dev/discord-bot)&nbsp;[![Share on X](https://img.shields.io/badge/X-share-black)](https://twitter.com/intent/tweet?text=%40dosu_ai%20helped%20me%20solve%20this%20issue!&url=https%3A//github.com/better-auth/better-auth/issues/5767)
Author
Owner

@Rvvvv1 commented on GitHub (Nov 6, 2025):

@dosu 我现在已经可以搜索并过滤出role为admin的用户。如果此时我想在过滤改账户是否被ban 怎么做呢?好像并没有多余的字段允许我扩展

<!-- gh-comment-id:3495769504 --> @Rvvvv1 commented on GitHub (Nov 6, 2025): @dosu 我现在已经可以搜索并过滤出role为admin的用户。如果此时我想在过滤改账户是否被ban 怎么做呢?好像并没有多余的字段允许我扩展
Author
Owner

@dosubot[bot] commented on GitHub (Nov 6, 2025):

目前 listUsers API 只支持单字段过滤(比如 role 或 banned),不支持同时传多个 filterField。如果你想筛选出 role=admin 且已被 ban 的用户,API 层面无法一次性实现。

你可以这样做:

  1. 先用 filterField: "role", filterOperator: "eq", filterValue: "admin" 拉取所有 admin 用户;
  2. 前端再用 user.banned === true 进行二次筛选。

比如:

const { users } = await authClient.admin.listUsers({
  query: {
    filterField: "role",
    filterOperator: "eq",
    filterValue: "admin",
    limit: 100,
  }
});
const bannedAdmins = users.filter(u => u.banned);

如果你只想查被 ban 的用户,可以直接用 filterField: "banned", filterOperator: "eq", filterValue: true 查询。

目前没有多字段扩展的参数,后续如有多条件过滤支持会在 changelog 里说明。需要更复杂的筛选只能前端处理。

To reply, just mention @dosu.


How did I do? Good | Irrelevant | Incorrect | Verbose | Hallucination | Report 🐛 | Other  Chat with Dosu Join Discord Share on X

<!-- gh-comment-id:3495787803 --> @dosubot[bot] commented on GitHub (Nov 6, 2025): <!-- Answer --> 目前 listUsers API 只支持单字段过滤(比如 role 或 banned),不支持同时传多个 filterField。如果你想筛选出 role=admin 且已被 ban 的用户,API 层面无法一次性实现。 你可以这样做: 1. 先用 filterField: "role", filterOperator: "eq", filterValue: "admin" 拉取所有 admin 用户; 2. 前端再用 user.banned === true 进行二次筛选。 比如: ```js const { users } = await authClient.admin.listUsers({ query: { filterField: "role", filterOperator: "eq", filterValue: "admin", limit: 100, } }); const bannedAdmins = users.filter(u => u.banned); ``` 如果你只想查被 ban 的用户,可以直接用 filterField: "banned", filterOperator: "eq", filterValue: true 查询。 目前没有多字段扩展的参数,后续如有多条件过滤支持会在 changelog 里说明。需要更复杂的筛选只能前端处理。 <!-- Dosu Comment Footer --> *To reply, just mention [@dosu](https://go.dosu.dev/dosubot).* --- <sup>How did I do? [Good](https://app.dosu.dev/response-feedback/99e93081-5513-4b4f-aa57-1e416494fcaf?feedback_type=great_response) | [Irrelevant](https://app.dosu.dev/response-feedback/99e93081-5513-4b4f-aa57-1e416494fcaf?feedback_type=irrelevant_answer) | [Incorrect](https://app.dosu.dev/response-feedback/99e93081-5513-4b4f-aa57-1e416494fcaf?feedback_type=incorrect_sources) | [Verbose](https://app.dosu.dev/response-feedback/99e93081-5513-4b4f-aa57-1e416494fcaf?feedback_type=too_verbose) | [Hallucination](https://app.dosu.dev/response-feedback/99e93081-5513-4b4f-aa57-1e416494fcaf?feedback_type=hallucination) | [Report 🐛](https://app.dosu.dev/response-feedback/99e93081-5513-4b4f-aa57-1e416494fcaf?feedback_type=bug_report) | [Other](https://app.dosu.dev/response-feedback/99e93081-5513-4b4f-aa57-1e416494fcaf?feedback_type=other)</sup>&nbsp;&nbsp;[![Chat with Dosu](https://dosu.dev/dosu-chat-badge.svg)](https://app.dosu.dev/cdda13d9-dd27-4d31-b09a-5d8bec92de21/ask?utm_source=github)&nbsp;[![Join Discord](https://img.shields.io/badge/join-5865F2?logo=discord&logoColor=white&label=)](https://go.dosu.dev/discord-bot)&nbsp;[![Share on X](https://img.shields.io/badge/X-share-black)](https://twitter.com/intent/tweet?text=%40dosu_ai%20helped%20me%20solve%20this%20issue!&url=https%3A//github.com/better-auth/better-auth/issues/5767)
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/better-auth#18974