invoke-ai/InvokeAI · error · HTTPException

Failed to get image names for date

Error message

Failed to get image names for date

What it means

HTTP 500 raised by list_virtual_board_image_names_by_date when fetching image names for a specific date fails in the gallery service. Any underlying exception is masked as HTTPException(500, detail='Failed to get image names for date').

Source

Thrown at invokeai/app/api/routers/virtual_boards.py:62

    search_term: str | None = Query(default=None, description="Search term to filter images"),
) -> ImageNamesResult:
    """Gets ordered image names for a specific date. Image-only.

    Deprecated: use `GET /v1/gallery/item_names?created_date=<date>`, which covers images and
    videos in one ordered list.
    """
    try:
        return ApiDependencies.invoker.services.image_records.get_image_names_by_date(
            date=date,
            starred_first=starred_first,
            order_dir=order_dir,
            categories=categories,
            search_term=search_term,
            user_id=current_user.user_id,
            is_admin=current_user.is_admin,
        )
    except Exception:
        raise HTTPException(status_code=500, detail="Failed to get image names for date")


@virtual_boards_router.get(
    "/by_date/{date}/item_names",
    operation_id="list_virtual_board_item_names_by_date",
    response_model=GalleryItemNamesResult,
    deprecated=True,
)
def list_virtual_board_item_names_by_date(
    current_user: CurrentUserOrDefault,
    date: str = Path(description="The ISO date string, e.g. '2026-03-18'"),
    starred_first: bool = Query(default=True, description="Whether to sort starred items first"),
    order_dir: SQLiteDirection = Query(default=SQLiteDirection.Descending, description="The sort direction"),
    categories: list[ImageCategory] | None = Query(default=None, description="The categories of items to include"),
    search_term: str | None = Query(default=None, description="Search term to filter items"),
) -> GalleryItemNamesResult:
    """Gets ordered polymorphic (image + video) item refs for a specific date.

View on GitHub (pinned to 0b6a024f2f)

Solutions

  1. Ensure the date path segment is a valid date string (e.g. 2024-01-15) the server can parse
  2. Drop the categories/search_term query params to isolate the failing filter
  3. Check server logs for the original exception to see the service-level cause
  4. Verify gallery DB tables exist and are migrated

Example fix

// before
requests.get(base + '/api/v1/virtual_boards/by_date/2024-13-45/image_names')  # invalid date
// after
d = datetime.date(2024, 1, 15).isoformat()
requests.get(base + f'/api/v1/virtual_boards/by_date/{d}/image_names')
Defensive patterns

Strategy: validation

Validate before calling

// validate the date path segment is ISO YYYY-MM-DD before calling
function isValidDate(s) {
  if (!/^\d{4}-\d{2}-\d{2}$/.test(s)) return false;
  const d = new Date(s + 'T00:00:00Z');
  return !isNaN(d.getTime()) && d.toISOString().slice(0, 10) === s;
}
if (!isValidDate(date)) throw new Error(`bad date: ${date}`);

Prevention

When it happens

Trigger: GET /api/v1/virtual_boards/by_date/{date}/image_names with an unparseable or out-of-range date, or when the underlying gallery query (categories/search_term filters) raises.

Common situations: Malformed date string in the path; filtering by categories that map to no valid column; DB errors on large galleries; timezone-parsing differences causing invalid date objects.

Related errors


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