invoke-ai/InvokeAI · warning · HTTPException

Invalid request: Must provide either 'all' or both 'offset'

Error message

Invalid request: Must provide either 'all' or both 'offset' and 'limit'

What it means

HTTP 400 raised by list_boards when the request supplies neither all=true nor both offset and limit query parameters. The endpoint requires exactly one of these two pagination modes and rejects ambiguous/empty calls.

Source

Thrown at invokeai/app/api/routers/boards.py:231

    current_user: CurrentUserOrDefault,
    order_by: BoardRecordOrderBy = Query(default=BoardRecordOrderBy.CreatedAt, description="The attribute to order by"),
    direction: SQLiteDirection = Query(default=SQLiteDirection.Descending, description="The direction to order by"),
    all: Optional[bool] = Query(default=None, description="Whether to list all boards"),
    offset: Optional[int] = Query(default=None, description="The page offset"),
    limit: Optional[int] = Query(default=None, description="The number of boards per page"),
    include_archived: bool = Query(default=False, description="Whether or not to include archived boards in list"),
) -> Union[OffsetPaginatedResults[BoardDTO], list[BoardDTO]]:
    """Gets a list of boards for the current user, including shared boards. Admin users see all boards."""
    if all:
        return ApiDependencies.invoker.services.boards.get_all(
            current_user.user_id, current_user.is_admin, order_by, direction, include_archived
        )
    elif offset is not None and limit is not None:
        return ApiDependencies.invoker.services.boards.get_many(
            current_user.user_id, current_user.is_admin, order_by, direction, offset, limit, include_archived
        )
    else:
        raise HTTPException(
            status_code=400,
            detail="Invalid request: Must provide either 'all' or both 'offset' and 'limit'",
        )


@boards_router.get(
    "/{board_id}/image_names",
    operation_id="list_all_board_image_names",
    response_model=list[str],
)
def list_all_board_image_names(
    current_user: CurrentUserOrDefault,
    board_id: str = Path(description="The id of the board or 'none' for uncategorized images"),
    categories: list[ImageCategory] | None = Query(default=None, description="The categories of image to include."),
    is_intermediate: bool | None = Query(default=None, description="Whether to list intermediate images."),
) -> list[str]:
    """Gets a list of images for a board"""

View on GitHub (pinned to 0b6a024f2f)

Solutions

  1. Pass all=true to fetch every board
  2. Or pass both offset and limit, e.g. ?offset=0&limit=20
  3. Fix client pagination code so offset and limit are always sent together

Example fix

// before
fetch('/api/v1/boards/?offset=0'); // 400
// after
fetch('/api/v1/boards/?offset=0&limit=20');
Defensive patterns

Strategy: validation

Validate before calling

const params = new URLSearchParams();
if (all) params.set('all', 'true');
else {
  if (offset == null || limit == null) throw new Error('listBoards needs all=true or both offset and limit');
  params.set('offset', String(offset)); params.set('limit', String(limit));
}

Type guard

const isListBoardsQuery = (q) =>
  q?.all === true || (Number.isInteger(q?.offset) && Number.isInteger(q?.limit));

Try / catch

try {
  return await api.get('/boards/', { params });
} catch (e) {
  if (e.response?.status === 400) throw new Error('Invalid pagination: pass all=true or offset+limit');
  throw e;
}

Prevention

When it happens

Trigger: GET /boards/ with no query params; or GET /boards/?offset=0 (limit missing); or GET /boards/?limit=10 (offset missing).

Common situations: Hand-written curl tests omitting pagination params; pagination state lost after a frontend refactor; API clients constructed with defaults that drop undefined query keys.

Understand the failure class

Background: Missing required parameter errors: what 'X is required' and 'the required X param is missing' mean, and how to fix them — this error's family across 27 libraries.

Related errors


AI-assisted analysis of invoke-ai/InvokeAI@0b6a024f2f (2026-08-29). Data as JSON: /api/errors/6b603b56d0f63982. Report an issue: GitHub.