Repository navigation
Feature: Allow page_size max value 100 - #15292
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (15)
🚧 Files skipped from review as they are similar to previous changes (9)
📝 WalkthroughWalkthroughCentralizes REST page-size constraints by adding ChangesPagination Validation Enforcement
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Suggested labels
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (3 passed)
✏️ 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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
test/unit_test/api/utils/test_doc_validation.py (1)
40-48: ⚡ Quick winAdd 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
📒 Files selected for processing (11)
api/apps/restful_apis/agent_api.pyapi/apps/restful_apis/chat_api.pyapi/apps/restful_apis/chunk_api.pyapi/apps/restful_apis/connector_api.pyapi/apps/restful_apis/dataset_api.pyapi/apps/restful_apis/document_api.pyapi/apps/restful_apis/mcp_api.pyapi/apps/restful_apis/memory_api.pyapi/apps/restful_apis/search_api.pyapi/utils/validation_utils.pytest/unit_test/api/utils/test_doc_validation.py
| 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 |
There was a problem hiding this comment.
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 Report✅ All modified and coverable lines are covered by tests. 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. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
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
📒 Files selected for processing (10)
test/testcases/test_http_api/common.pytest/testcases/test_http_api/test_session_management/test_agent_completions.pytest/testcases/test_http_api/test_session_management/test_agent_sessions.pytest/testcases/test_sdk_api/common.pytest/testcases/test_sdk_api/conftest.pytest/testcases/test_sdk_api/test_chat_assistant_management/conftest.pytest/testcases/test_sdk_api/test_chunk_management_within_dataset/conftest.pytest/testcases/test_sdk_api/test_file_management_within_dataset/test_parse_documents.pytest/testcases/test_sdk_api/test_file_management_within_dataset/test_stop_parse_documents.pytest/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): |
There was a problem hiding this comment.
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).
|
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)] |
Feature: Allow page_size max value 100