ruvnet/RuView · warning · HTTPException

Size must be <= {max_size}

Error message

Size must be <= {max_size}

What it means

Raised as HTTP 400 by PaginationParams at dependencies.py:350 when `size` exceeds `max_size` (default 100). The cap protects the service and database from oversized single responses. The detail is an f-string, so the wire message reads e.g. 'Size must be <= 100'.

Source

Thrown at archive/v1/src/api/dependencies.py:350

        self,
        page: int = 1,
        size: int = 20,
        max_size: int = 100
    ):
        if page < 1:
            raise HTTPException(
                status_code=status.HTTP_400_BAD_REQUEST,
                detail="Page must be >= 1"
            )
        
        if size < 1:
            raise HTTPException(
                status_code=status.HTTP_400_BAD_REQUEST,
                detail="Size must be >= 1"
            )
        
        if size > max_size:
            raise HTTPException(
                status_code=status.HTTP_400_BAD_REQUEST,
                detail=f"Size must be <= {max_size}"
            )
        
        self.page = page
        self.size = size
        self.offset = (page - 1) * size
        self.limit = size


def get_pagination_params(
    page: int = 1,
    size: int = 20
) -> PaginationParams:
    """Get pagination parameters."""
    return PaginationParams(page=page, size=size)

View on GitHub (pinned to 4685618388)

Solutions

  1. Request at most 100 items per page and follow pagination for the remainder
  2. Page through with page/size instead of one oversized request
  3. If you operate the server and must allow bigger pages, raise max_size where the dependency constructs PaginationParams (get_pagination_params) rather than deleting the check

Example fix

# before
params = PaginationParams(page=page, size=size)

# after (allow up to 500 on this route)
params = PaginationParams(page=page, size=size, max_size=500)
Defensive patterns

Strategy: validation

Validate before calling

MAX_PAGE_SIZE = 100
size = min(int(desired_size), MAX_PAGE_SIZE)  # page through for the remainder

Type guard

def is_valid_size(size, max_size=100) -> bool:
    return isinstance(size, int) and 1 <= size <= max_size

Try / catch

resp = await client.get('/api/v1/detections', params=params)
if resp.status_code == 400 and 'Size must be <=' in resp.json().get('detail', ''):
    params['size'] = 100
    resp = await client.get('/api/v1/detections', params=params)
resp.raise_for_status()

Prevention

When it happens

Trigger: ?size=101 or higher on any endpoint using get_pagination_params with the default max_size=100, or exceeding a custom max_size a route passes to PaginationParams.

Common situations: A dashboard tries to load a full table in one request; the server team changed max_size and a deployed client still sends the old page size; copying a size from another endpoint with a different cap.

Related errors


AI-assisted analysis of ruvnet/RuView@4685618388 (2026-08-16). Data as JSON: /api/errors/b3e9e7a675cd17d2. Report an issue: GitHub.