{"record":{"id":"67082cfd73bd9992","repo":"invoke-ai/InvokeAI","slug":"failed-to-get-image-names","errorCode":null,"errorMessage":"Failed to get image names","messagePattern":"Failed to get image names","errorType":"http","errorClass":"HTTPException","httpStatus":500,"severity":"error","filePath":"invokeai/app/api/routers/images.py","lineNumber":887,"sourceCode":"    # Validate that the caller can read from this board before listing its images.\n    if board_id is not None and board_id != \"none\":\n        _assert_board_read_access(board_id, current_user)\n\n    try:\n        result = ApiDependencies.invoker.services.images.get_image_names(\n            starred_first=starred_first,\n            order_dir=order_dir,\n            image_origin=image_origin,\n            categories=categories,\n            is_intermediate=is_intermediate,\n            board_id=board_id,\n            search_term=search_term,\n            user_id=current_user.user_id,\n            is_admin=current_user.is_admin,\n        )\n        return result\n    except Exception:\n        raise HTTPException(status_code=500, detail=\"Failed to get image names\")\n\n\n@images_router.post(\n    \"/images_by_names\",\n    operation_id=\"get_images_by_names\",\n    responses={200: {\"model\": list[ImageDTO]}},\n)\ndef get_images_by_names(\n    current_user: CurrentUserOrDefault,\n    image_names: list[ImageName] = Body(\n        embed=True,\n        description=\"Object containing list of image names to fetch DTOs for\",\n        max_length=MAX_IMAGE_BATCH_SIZE,\n    ),\n) -> list[ImageDTO]:\n    \"\"\"Gets image DTOs for the specified image names. Maintains order of input names.\"\"\"\n\n    try:","sourceCodeStart":869,"sourceCodeEnd":905,"githubUrl":"https://github.com/invoke-ai/InvokeAI/blob/0b6a024f2ff6a86bfb953dcdb9cc504ef7397a06/invokeai/app/api/routers/images.py#L869-L905","documentation":"HTTP 500 raised by the image-names search endpoint when the underlying search/list call throws. The endpoint passes search_term, user_id and is_admin into the service and wraps any exception in this generic detail.","triggerScenarios":"GET /api/v1/images/names (with categories/search_term params) when the images service search fails — DB error, malformed search term handled improperly, or service unavailable.","commonSituations":"Special characters in search_term hitting an unescaped query path; sqlite locked or corrupted; API version mismatch where the client sends params the server service no longer accepts.","solutions":["Check server logs for the original traceback","Retry with a simpler/empty search_term to isolate the term","Verify database availability and integrity","Restart InvokeAI if services are in a bad state"],"exampleFix":null,"handlingStrategy":"retry","validationCode":"// sanitize the search term before calling\nconst term = (searchTerm ?? '').trim().slice(0, 200);","typeGuard":null,"tryCatchPattern":"try {\n  const names = await api.getImageNames({ search_term: term });\n} catch (e) {\n  if (e instanceof ApiError && e.status === 500) {\n    // retry once with empty search_term; alert if it still fails\n  }\n}","preventionTips":["Trim/sanitize search terms client-side","Fall back to unfiltered listing when search fails","Monitor DB health; restart on lock errors","Keep client params aligned with the server API version"],"tags":["http-500","search","api"],"backgroundTag":"image-search-failed","analyzedSha":"0b6a024f2ff6a86bfb953dcdb9cc504ef7397a06","analyzedAt":"2026-08-29T04:46:49.967Z","schemaVersion":2},"datasetVersion":"2026-08-29T07:17:48.351Z"}