Skip to content

fix(search): prevent large page offset overflow - #1106

Merged
XiaoSeS merged 3 commits into
iflytek:mainfrom
XuXcode:codex/skillhub-search-offset-overflow
Nov 19, 2026
Merged

XiaoSeS merged 3 commits into
iflytek:mainfrom
XuXcode:codex/skillhub-search-offset-overflow

Conversation

@XuXcode

@XuXcode XuXcode commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

Problem

The search offset is calculated using int multiplication, which can overflow for large page numbers.

For example, with page=107374183 and size=20, the expected offset is 2147483660, but the actual result is -2147483636.

Changes

  • Use long for offset calculation, SQL parameter binding, and semantic reranking.
  • Add a regression test for large page offsets.

Testing

  • PostgresFullTextQueryServiceTest: 26 tests passed.
  • git diff --check: passed.
  • Verified SQL parameter binding through a regression unit test.

AI assistance was used during testing. I personally reviewed the code changes before submission.

Maintainer validation:

  • Synced the latest main without rewriting the contributor's commits.
  • Added a real PostgreSQL regression covering offsets beyond signed 32-bit range and Integer.MAX_VALUE pages across all three sorts and source filters; authorized totals and normal-page behavior remain intact.
  • Original 26 query tests passed; 45 focused query/controller/PostgreSQL tests passed on PostgreSQL 16, and the three PostgreSQL integration tests passed again on PostgreSQL 17.
  • Exact-head local release images and S3/auth-entry/protected-path smoke passed. Real search requests return empty items and unchanged nonzero totals for huge pages, while preserving legacy invalid-page fallback behavior.
  • 13 completed remote checks passed, with CodeQL skipped. The pre-existing E2E workflow remains awaiting approval and is not counted as passed; the general E2E stale-contract and timeout work is tracked separately in test(e2e): align market regression coverage and bound CI runs #1108.

Signed-off-by: XuX <841130121@qq.com>
@CLAassistant

CLAassistant commented Nov 19, 2026 •

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@CLAassistant

Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

Signed-off-by: XiaoSeS <87064762+XiaoSeS@users.noreply.github.com>
Signed-off-by: XiaoSeS <87064762+XiaoSeS@users.noreply.github.com>
@XiaoSeS
XiaoSeS merged commit 39debd7 into iflytek:main Nov 19, 2026
15 checks 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.

3 participants