Significant-Gravitas/AutoGPT · warning · HTTPException

Page size must be greater than 0

Error message

Page size must be greater than 0

What it means

HTTP 422 from GET /api/v1/store/agents (external store API). The `page_size` query parameter was parsed as an integer but is < 1 (0 or negative), failing the route's manual check. The store cache lookup is never reached.

Source

Thrown at autogpt_platform/backend/backend/api/external/v1/routes.py:352

    Get a paginated list of agents from the store with optional filtering and sorting.

    Args:
        featured: Filter to only show featured agents
        creator: Filter agents by creator username
        sorted_by: Sort agents by "runs", "rating", "name", or "updated_at"
        search_query: Search agents by name, subheading and description
        category: Filter agents by category
        page: Page number for pagination (default 1)
        page_size: Number of agents per page (default 20)

    Returns:
        StoreAgentsResponse: Paginated list of agents matching the filters
    """
    if page < 1:
        raise HTTPException(status_code=422, detail="Page must be greater than 0")

    if page_size < 1:
        raise HTTPException(status_code=422, detail="Page size must be greater than 0")

    agents = await store_cache._get_cached_store_agents(
        featured=featured,
        creator=creator,
        sorted_by=sorted_by,
        search_query=search_query,
        category=category,
        page=page,
        page_size=page_size,
    )
    return agents


@v1_router.get(
    path="/store/agents/{username}/{agent_name}",
    tags=["store"],
    dependencies=[Security(require_auth)],  # data is public; auth required as anti-DDoS
    response_model=store_model.StoreAgentDetails,

View on GitHub (pinned to 9c8bb5550f)

Solutions

  1. Send a positive page_size (default is 20).
  2. Guard dynamic sizes client-side: page_size = Math.max(1, computedSize).
  3. Treat unset/0 configuration as the default 20 rather than forwarding it.

Example fix

// before
const size = list.length ? 20 : list.length; // sends 0

// after
const size = 20; // keep a positive constant default
Defensive patterns

Strategy: validation

Validate before calling

const pageSize = Number.isInteger(raw) && raw >= 1 ? raw : 20;

Type guard

function isValidPageSize(n: number): boolean { return Number.isInteger(n) && n >= 1; }

Prevention

When it happens

Trigger: GET /api/v1/store/agents?page_size=0, ?page_size=-5, or a page_size computed from an empty list length (e.g. total/total=0) in client code.

Common situations: Dynamic page sizing where size derives from a result count that is 0; UI 'items per page' selector allowing an empty/zero entry; env-configured page size defaulting to 0 when unset.

Related errors


AI-assisted analysis of Significant-Gravitas/AutoGPT@9c8bb5550f (2026-08-14). Data as JSON: /api/errors/53d5ad351bb8ec61. Report an issue: GitHub.