Skip to content

fix(pagination): bound list queries and preserve workspace candidates - #1477

Merged
fit2cloud-chenyw merged 4 commits into
dataease:mainfrom
borealisalastor-byte:fix/pagination-args
Nov 20, 2026
Merged

fit2cloud-chenyw merged 4 commits into
dataease:mainfrom
borealisalastor-byte:fix/pagination-args

Conversation

@borealisalastor-byte

@borealisalastor-byte borealisalastor-byte commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

List endpoints using the shared paginator accepted zero or negative page sizes and unbounded sizes. Zero sizes caused division by zero, and invalid or extremely large offsets could fail at the database boundary.

  • Normalize page < 1 to 1, size < 1 to 20, and size > 500 to 500. Use the effective values consistently for queries and response metadata.
  • Return an empty page after counting when the offset is beyond the result set, avoiding oversized integer bindings while retaining the requested valid page number.
  • Load workspace member candidates in batches of 500 so the existing selection dialog still includes users beyond the first page. A failed later batch does not expose an incomplete candidate list.

Validation on main 5f1cd86 plus this change:

  • Shared paginator tests: 17 passed, including real SQLite queries with 543 synthetic rows, LIMIT/OFFSET bindings, normal pages, empty results, zero/negative/oversized sizes, and page=10**30. The added tests reproduced three failures before the optimization.
  • Playwright CLI reproduced the old dialog requesting size=1000000 once and omitting the last candidate under the server cap.
  • Playwright component regression: 3 passed, covering selection and save beyond 500 candidates, empty lists, and later-page failure.
  • Frontend production build, targeted ESLint, test-file Ruff, and diff whitespace checks passed.

Scope: shared user/workspace-member/system-variable pagination. Independent terminology and SQL-example pagination is unchanged. SQLite and isolated browser HTTP fixtures do not replace PostgreSQL or full authentication/authorization deployment validation. The limit bounds returned rows per request; count/filter scan cost and the dialog's total in-memory candidate set remain proportional to the data.

Fixes #1476

@fit2cloud-chenyw fit2cloud-chenyw self-assigned this Nov 20, 2026
@fit2cloud-chenyw fit2cloud-chenyw changed the title fix(pagination): clamp out-of-range page and size #1476 fix(pagination): bound list queries and preserve workspace candidates Nov 20, 2026
@fit2cloud-chenyw

Copy link
Copy Markdown
Contributor

复核结论:提交 75771098c7295cc6cf6951bb7e7bfff8168e7cd9 在本 PR 的共享分页器范围内可以合并。

  • page < 1、size < 1 和 size > 500 的归一化值一致用于查询、总页数及响应;超出总页数时直接返回空列表,避免极大 OFFSET 的数据库整数溢出。
  • 工作空间授权弹窗按每页 500 条加载后续候选用户,搜索、勾选和保存方式保持一致;后续页失败时不展示不完整候选列表。
  • 已修复评审发现的 SQLite 测试隔离问题,仅创建分页测试自己的表。分页和知识生命周期回归联合运行 36 项通过,测试文件 Ruff 检查和格式检查通过。
  • 本 PR 的相同前端业务代码此前已通过完整构建、定向 ESLint 和 3 项 Playwright 组件回归,覆盖第 543 个候选用户的搜索/选择/保存、空列表及后续页失败;Playwright CLI 保留了原弹窗遗漏末页用户的对照证据。最终追加提交仅修改测试建表范围。

兼容性说明:外部 API 调用方请求超过 500 条时需要继续翻页;候选用户较多时弹窗增加分批请求,打开可能更慢。该限制约束单次返回条数,不限制 count 的扫描成本或弹窗最终持有的全部候选数据。独立术语/SQL 示例分页不在本 PR 范围内。尚未执行 PostgreSQL、完整认证授权链及完整部署验收,现有验证不等同于这些层级通过。

@fit2cloud-chenyw
fit2cloud-chenyw merged commit f399e6e into dataease:main Nov 20, 2026
1 check passed
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.

[BUG] 分页接口未校验 page/size:size=0 触发除零 500,page=0 产生负 OFFSET

2 participants