Repository navigation
test(nlp): add pagination guard coverage for RetrievalService.Retrieval - #21557
Conversation
|
Important Review skippedReview was skipped as selected files did not have any reviewable changes.
|
| Layer / File(s) | Summary |
|---|---|
Retrieval guard and reranking coverage internal/service/nlp/retrieval_test.go |
Adds tests for pagination rejection when reranking is configured, missing rerank_candidates_count guard precedence, and page-one retrieval passing one document to the reranker. |
Priority:
Estimated code review effort: 2 (Simple) | ~10 minutes
Change: Other
Possibly related PRs
- infiniflow/ragflow#21075: Changes the candidate-pool pagination guard that these tests exercise.
- infiniflow/ragflow#20941: Adds coverage for pagination and first-page reranking restrictions in retrieval.
- infiniflow/ragflow#21427: Changes the request contract for
RerankCandidatesCount, which the pagination guard checks.
Suggested reviewers: wangq8, qinling0210, 6ba3i
Merge Risk: 
Minimal · previous review f39b6
-
The change adds retrieval tests without an identified merge-blocking issue.
Pre-merge checks: 
4 · 
1
-
Failed checks: 1 warning Passed checks: 4 passed-
Full details: Title check
-
Explanation
The title is a conventional-commit style summary that names the scope (nlp), the type (test), and the specific subject (pagination guard coverage for RetrievalService.Retrieval). The raw summary and objectives confirm the changeset adds three package-level tests for the rerank pagination guards and makes no production changes, so the title matches the main change.
Full details: Description check
-
Explanation
The description has a Summary section, which is the only heading in the template. It explains the purpose and background: the rerank pagination guards lacked direct coverage, the page != 1 rejection was never reached, and the three tests mirror a Python 0.27.x test file. It also states that no production code changes. The template asks only for a brief summary with background context, and the author provides both, so the description is mostly complete.
-
Full details: Docstring Coverage
-
Explanation
Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 3 functions across 1 files.
Resolution
Write docstrings for the functions missing them to satisfy the coverage threshold.
-
- Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
A rabbit checks page one with care,
Then asks if reranking can go there.
Page two receives a guarded no,
Missing counts take precedence, so.
One document joins the reranker’s queue,
The tests record what it should do.
Comment @coderabbitai help to get the list of available commands.
There was a problem hiding this comment.
Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota.
An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing.
Summary
Add package-level tests for the rerank pagination guards in RetrievalService.Retrieval. Neither guard had direct coverage: the only existing page-related unit test asserted the candidate-set slicing, and the REST suite exercised only the unknown-rerank_id failure, so the page != 1 rejection in retrieval.go:146 was never reached.
The three tests mirror Python 0.27.x's test/unit_test/rag/test_search_pagination.py: one verifies that a non-nil RerankModel with page=2 (inside the candidates window) is rejected with "Pagination is not supported"; a second pins the ordering contract that the rerank_candidates_count guard wins over the pagination guard when page*page_size overflows the window; and a third asserts the page=1 positive path still reaches the cross-encoder via captureDriver. No production code changes.
REST-level coverage of the resolved-rerank-model path is intentionally omitted: Python 0.27.x never carried a page+rerank combination at that layer either.