mirror of
https://github.com/infiniflow/ragflow.git
synced 2026-08-15 05:04:27 +08:00
Fix: restrict xxx_ids to limit 100 (#18074)
This commit is contained in:
@@ -17,6 +17,7 @@
|
||||
DEFAULT_PAGE = 1
|
||||
DEFAULT_PAGE_SIZE = 30
|
||||
REST_API_MAX_PAGE_SIZE = 100
|
||||
REST_API_MAX_IDS = 100
|
||||
|
||||
|
||||
def validate_rest_api_page(page) -> int:
|
||||
@@ -41,3 +42,10 @@ def validate_rest_api_page_size(page_size) -> int:
|
||||
if int_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 int_page_size
|
||||
|
||||
|
||||
def validate_rest_api_ids(ids: list | None, field_name: str = "ids") -> list | None:
|
||||
"""Validate REST API ID lists against the public maximum."""
|
||||
if ids is not None and len(ids) > REST_API_MAX_IDS:
|
||||
raise ValueError(f"{field_name} must contain at most {REST_API_MAX_IDS} IDs")
|
||||
return ids
|
||||
|
||||
@@ -30,7 +30,7 @@ from werkzeug.exceptions import BadRequest, UnsupportedMediaType
|
||||
|
||||
from api.constants import DATASET_NAME_LIMIT, FILE_NAME_LEN_LIMIT
|
||||
from api.db import FileType
|
||||
from api.utils.pagination_utils import validate_rest_api_page_size
|
||||
from api.utils.pagination_utils import REST_API_MAX_IDS, validate_rest_api_page_size
|
||||
from common.constants import RetCode
|
||||
|
||||
|
||||
@@ -1043,7 +1043,7 @@ class BaseListReq(BaseModel):
|
||||
class ListDatasetReq(BaseListReq):
|
||||
"""Request model for listing datasets."""
|
||||
|
||||
ids: Annotated[list[str] | None, Field(default=None)]
|
||||
ids: Annotated[list[str] | None, Field(default=None, max_length=REST_API_MAX_IDS)]
|
||||
include_parsing_status: Annotated[bool, Field(default=False)]
|
||||
ext: Annotated[dict, Field(default={})]
|
||||
|
||||
|
||||
Reference in New Issue
Block a user