Skip to content

Feature: Allow page_size max value 100 - #15292

Merged
wangq8 merged 3 commits into
infiniflow:mainfrom
wangq8:feature/allow-max-page_size-as-100
May 28, 2026
Merged

wangq8 merged 3 commits into
infiniflow:mainfrom
wangq8:feature/allow-max-page_size-as-100

Conversation

@wangq8

@wangq8 wangq8 commented May 27, 2026

Copy link
Copy Markdown
Collaborator

Feature: Allow page_size max value 100

@wangq8 wangq8 added the ci Continue Integration label May 27, 2026
@coderabbitai

coderabbitai Bot commented May 27, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: cc43fe15-c40c-451b-8491-a5e9c09fd9f4

📥 Commits

Reviewing files that changed from the base of the PR and between e78584a and 42b4d88.

📒 Files selected for processing (15)
  • api/apps/restful_apis/agent_api.py
  • api/apps/restful_apis/chat_api.py
  • api/apps/restful_apis/chunk_api.py
  • api/apps/restful_apis/connector_api.py
  • api/apps/restful_apis/dataset_api.py
  • api/apps/restful_apis/document_api.py
  • api/apps/restful_apis/mcp_api.py
  • api/apps/restful_apis/memory_api.py
  • api/apps/restful_apis/search_api.py
  • api/utils/pagination_utils.py
  • api/utils/validation_utils.py
  • test/playwright/conftest.py
  • test/testcases/restful_api/test_chunks.py
  • test/testcases/test_sdk_api/test_dataset_mangement/test_create_dataset.py
  • test/unit_test/api/utils/test_doc_validation.py
🚧 Files skipped from review as they are similar to previous changes (9)
  • api/apps/restful_apis/dataset_api.py
  • api/apps/restful_apis/memory_api.py
  • test/unit_test/api/utils/test_doc_validation.py
  • api/apps/restful_apis/search_api.py
  • api/apps/restful_apis/chat_api.py
  • api/apps/restful_apis/document_api.py
  • api/apps/restful_apis/chunk_api.py
  • api/apps/restful_apis/mcp_api.py
  • api/apps/restful_apis/agent_api.py

📝 Walkthrough

Walkthrough

Centralizes REST page-size constraints by adding REST_API_MAX_PAGE_SIZE and validate_rest_api_page_size(), applying the validator in Pydantic list-request models and across multiple REST listing endpoints, and updating unit and integration test helpers to use the enforced page-size limits.

Changes

Pagination Validation Enforcement

Layer / File(s) Summary
Page-size validation framework and tests
api/utils/pagination_utils.py, api/utils/validation_utils.py, test/unit_test/api/utils/test_doc_validation.py
Adds REST_API_MAX_PAGE_SIZE = 100 and validate_rest_api_page_size(); adds Pydantic field validators that call the validator; adds unit tests that assert acceptance at 100 and rejection above it.
REST API endpoint pagination enforcement
api/apps/restful_apis/*, test helpers, playwright/conftest.py
Imports validate_rest_api_page_size and replaces direct int(...) parsing of page_size with validate_rest_api_page_size(...) across numerous listing endpoints; lowers multiple test helper default page_size values and updates tests to paginate using the new limits.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Suggested labels

💞 feature, 🐖api, 🧪 test, python

Suggested reviewers

  • yingfeng
  • KevinHuSh
  • JinHai-CN

Poem

🐰 A hundred hops, a tidy page,
The rabbit trims the pagination cage.
Endpoints ask, the validator minds,
Responses neat with bounded finds.
Hooray — the APIs bounce light and sage!

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Description check ⚠️ Warning The PR description lacks required template sections such as 'What problem does this PR solve?' and 'Type of change', providing only a title-level summary. Fill in the PR description template with details about the problem being solved, the type of change, and context for reviewers understanding the feature's purpose.
Docstring Coverage ⚠️ Warning Docstring coverage is 11.29% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main change: implementing a maximum page size limit of 100 across REST API endpoints.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@wangq8
wangq8 marked this pull request as ready for review May 27, 2026 07:49
@dosubot dosubot Bot added the size:M This PR changes 30-99 lines, ignoring generated files. label May 27, 2026

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (1)
test/unit_test/api/utils/test_doc_validation.py (1)

40-48: ⚡ Quick win

Add a pytest priority marker to the new test.

Line 40 introduces a new pytest test without a p1/p2/p3 marker. Please add the repo-standard marker so test selection remains consistent.

Suggested change
+@pytest.mark.p2
 def test_rest_api_page_size_rejects_values_above_100():

As per coding guidelines "test/**/*.py: Use pytest with priority markers (p1/p2/p3) for Python backend tests".

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@test/unit_test/api/utils/test_doc_validation.py` around lines 40 - 48, The
new unit test function test_rest_api_page_size_rejects_values_above_100 lacks a
repo-standard pytest priority marker; add the appropriate marker (e.g.,
`@pytest.mark.p1`) above the test definition to match other tests. Locate the
test_rest_api_page_size_rejects_values_above_100 function in
test/unit_test/api/utils/test_doc_validation.py and prepend the priority
decorator so the test selection respects the p1/p2/p3 convention (the test still
exercises validate_rest_api_page_size and the ListDatasetReq/ListFileReq
validations).
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@api/utils/validation_utils.py`:
- Around line 38-42: The validate_rest_api_page_size function currently raises
ValueError which is fine for Pydantic validators but can cause 5xx responses
when called directly from request handlers; add a route-safe wrapper (e.g.,
validate_rest_api_page_size_for_route) that calls validate_rest_api_page_size
and converts any ValueError into a client error (raise an HTTP 400/BadRequest
style exception or return a sanitized error object) so route input parsing
returns a 4xx validation response; update request-handler call sites to use
validate_rest_api_page_size_for_route while keeping validate_rest_api_page_size
unchanged for Pydantic usage.

---

Nitpick comments:
In `@test/unit_test/api/utils/test_doc_validation.py`:
- Around line 40-48: The new unit test function
test_rest_api_page_size_rejects_values_above_100 lacks a repo-standard pytest
priority marker; add the appropriate marker (e.g., `@pytest.mark.p1`) above the
test definition to match other tests. Locate the
test_rest_api_page_size_rejects_values_above_100 function in
test/unit_test/api/utils/test_doc_validation.py and prepend the priority
decorator so the test selection respects the p1/p2/p3 convention (the test still
exercises validate_rest_api_page_size and the ListDatasetReq/ListFileReq
validations).
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 19a4c842-f2a5-4a0d-9e98-1f63fae656bb

📥 Commits

Reviewing files that changed from the base of the PR and between 2c099bb and 4107651.

📒 Files selected for processing (11)
  • api/apps/restful_apis/agent_api.py
  • api/apps/restful_apis/chat_api.py
  • api/apps/restful_apis/chunk_api.py
  • api/apps/restful_apis/connector_api.py
  • api/apps/restful_apis/dataset_api.py
  • api/apps/restful_apis/document_api.py
  • api/apps/restful_apis/mcp_api.py
  • api/apps/restful_apis/memory_api.py
  • api/apps/restful_apis/search_api.py
  • api/utils/validation_utils.py
  • test/unit_test/api/utils/test_doc_validation.py

Comment thread api/utils/validation_utils.py Outdated
Comment on lines +38 to +42
def validate_rest_api_page_size(page_size: int) -> int:
"""Validate REST API page_size values against the public maximum."""
if page_size > REST_API_MAX_PAGE_SIZE:
raise ValueError(f"page_size must be less than or equal to {REST_API_MAX_PAGE_SIZE}")
return page_size

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major | 🏗️ Heavy lift

Separate Pydantic validation errors from route-input errors.

validate_rest_api_page_size raises ValueError, but it is now also used directly in request handlers (not only in Pydantic validators). For those handlers, oversize page_size can propagate as server errors instead of a client 4xx validation response. Please introduce a route-safe wrapper (or normalize ValueError at call sites) for request-arg parsing paths.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@api/utils/validation_utils.py` around lines 38 - 42, The
validate_rest_api_page_size function currently raises ValueError which is fine
for Pydantic validators but can cause 5xx responses when called directly from
request handlers; add a route-safe wrapper (e.g.,
validate_rest_api_page_size_for_route) that calls validate_rest_api_page_size
and converts any ValueError into a client error (raise an HTTP 400/BadRequest
style exception or return a sanitized error object) so route input parsing
returns a 4xx validation response; update request-handler call sites to use
validate_rest_api_page_size_for_route while keeping validate_rest_api_page_size
unchanged for Pydantic usage.

@codecov

codecov Bot commented May 27, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 93.16%. Comparing base (ae88578) to head (42b4d88).
⚠️ Report is 6 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main   #15292   +/-   ##
=======================================
  Coverage   93.16%   93.16%           
=======================================
  Files          10       10           
  Lines         717      717           
  Branches      118      118           
=======================================
  Hits          668      668           
  Misses         29       29           
  Partials       20       20           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@test/testcases/test_http_api/common.py`:
- Line 62: Remove the unused page_size parameter from the signatures of all
delete_all_* functions (e.g., delete_all_datasets) and from any internal
references; these functions always send {"ids": None, "delete_all": True} so
page_size is misleading. Edit each function signature to drop the page_size
kwarg, update any callers/tests to stop passing page_size, and adjust
docstrings/comments to reflect there is no pagination option. Ensure no other
code relies on the removed parameter (search for "delete_all_" function names to
locate all six instances).
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: a7da21a9-48e3-42df-bd91-06582d71183b

📥 Commits

Reviewing files that changed from the base of the PR and between 4107651 and e78584a.

📒 Files selected for processing (10)
  • test/testcases/test_http_api/common.py
  • test/testcases/test_http_api/test_session_management/test_agent_completions.py
  • test/testcases/test_http_api/test_session_management/test_agent_sessions.py
  • test/testcases/test_sdk_api/common.py
  • test/testcases/test_sdk_api/conftest.py
  • test/testcases/test_sdk_api/test_chat_assistant_management/conftest.py
  • test/testcases/test_sdk_api/test_chunk_management_within_dataset/conftest.py
  • test/testcases/test_sdk_api/test_file_management_within_dataset/test_parse_documents.py
  • test/testcases/test_sdk_api/test_file_management_within_dataset/test_stop_parse_documents.py
  • test/testcases/test_web_api/conftest.py
✅ Files skipped from review due to trivial changes (3)
  • test/testcases/test_sdk_api/test_file_management_within_dataset/test_parse_documents.py
  • test/testcases/test_web_api/conftest.py
  • test/testcases/test_sdk_api/common.py



def delete_all_datasets(auth, *, page_size=1000):
def delete_all_datasets(auth, *, page_size=100):

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Remove unused page_size parameter from all delete_all_* functions.

The page_size parameter is accepted but never used in any of these functions. Each function passes a static payload with {"ids": None, "delete_all": True} to the underlying delete API, which handles deletion server-side without client pagination. Accepting an unused parameter is misleading—it suggests the parameter affects behavior when it doesn't.

♻️ Proposed fix: Remove the parameter from all six functions
-def delete_all_datasets(auth, *, page_size=100):
+def delete_all_datasets(auth):
     return delete_datasets(auth, {"ids": None, "delete_all": True})
-def delete_all_documents(auth, dataset_id, *, page_size=100):
+def delete_all_documents(auth, dataset_id):
     return delete_documents(auth, dataset_id, {"ids": None, "delete_all": True})
-def delete_all_chunks(auth, dataset_id, document_id, *, page_size=100):
+def delete_all_chunks(auth, dataset_id, document_id):
     return delete_chunks(auth, dataset_id, document_id, {"chunk_ids": None, "delete_all": True})
-def delete_all_chat_assistants(auth, *, page_size=100):
+def delete_all_chat_assistants(auth):
     return delete_chat_assistants(auth, {"ids": None, "delete_all": True})
-def delete_all_sessions_with_chat_assistant(auth, chat_assistant_id, *, page_size=100):
+def delete_all_sessions_with_chat_assistant(auth, chat_assistant_id):
     return delete_session_with_chat_assistants(auth, chat_assistant_id, {"ids": None, "delete_all": True})
-def delete_all_agent_sessions(auth, agent_id, *, page_size=100):
+def delete_all_agent_sessions(auth, agent_id):
     return delete_agent_sessions(auth, agent_id, {"ids": None, "delete_all": True})

Also applies to: 136-136, 195-195, 250-250, 287-287, 381-381

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@test/testcases/test_http_api/common.py` at line 62, Remove the unused
page_size parameter from the signatures of all delete_all_* functions (e.g.,
delete_all_datasets) and from any internal references; these functions always
send {"ids": None, "delete_all": True} so page_size is misleading. Edit each
function signature to drop the page_size kwarg, update any callers/tests to stop
passing page_size, and adjust docstrings/comments to reflect there is no
pagination option. Ensure no other code relies on the removed parameter (search
for "delete_all_" function names to locate all six instances).

@wangq8
wangq8 merged commit 0aff6a3 into infiniflow:main May 28, 2026
1 of 2 checks passed
@zz80900

zz80900 commented Jun 15, 2026

Copy link
Copy Markdown
Contributor

Because you set the maximum value to 100, the MCP error 0 was triggered: [TextContent(type='text', text='Field: <page_size> - Message: <Value error, page_size must be less than or equal to 100> - Value: <1000>', annotations=None, meta=None)]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci Continue Integration size:M This PR changes 30-99 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants