ruvnet/RuView · warning · HTTPException

Size must be >= 1

Error message

Size must be >= 1

What it means

Raised as HTTP 400 by PaginationParams at dependencies.py:344 when the `size` query parameter is less than 1. `size` is used both as the SQL-style LIMIT and as the offset multiplier, so zero or negative sizes are meaningless and rejected before the route runs. The default size is 20.

Source

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

# Pagination dependencies
class PaginationParams:
    """Pagination parameters."""
    
    def __init__(
        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,

View on GitHub (pinned to 4685618388)

Solutions

  1. Send size >= 1 (default 20)
  2. For 'fetch all', page through results with size=100 instead of size=0
  3. Validate and clamp user input before building the query string

Example fix

# before
size = int(request.args.get('size', 0))

# after
size = max(1, min(int(request.args.get('size', 20)), 100))
Defensive patterns

Strategy: validation

Validate before calling

def safe_size(size, max_size=100):
    value = int(size) if size is not None else 20
    return max(1, value)  # pair with min(value, max_size) to also dodge the <=100 error

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 >= 1' in resp.json().get('detail', ''):
    params['size'] = 20
    resp = await client.get('/api/v1/detections', params=params)
resp.raise_for_status()

Prevention

When it happens

Trigger: Any endpoint using get_pagination_params called with ?size=0 or a negative size, e.g. GET /api/v1/detections?page=1&size=0.

Common situations: A 'fetch everything' attempt sends size=0 expecting it to mean unlimited; an empty UI input is parsed to 0 and sent; a caller sends -1 hoping for reversed paging.

Related errors


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