{"record":{"id":"2c007f251b7e7384","repo":"invoke-ai/InvokeAI","slug":"failed-to-get-image-dtos","errorCode":null,"errorMessage":"Failed to get image DTOs","messagePattern":"Failed to get image DTOs","errorType":"http","errorClass":"HTTPException","httpStatus":500,"severity":"error","filePath":"invokeai/app/api/routers/images.py","lineNumber":924,"sourceCode":"        image_service = ApiDependencies.invoker.services.images\n\n        # Fetch DTOs preserving the order of requested names\n        image_dtos: list[ImageDTO] = []\n        for name in image_names:\n            try:\n                _assert_image_read_access(name, current_user)\n                dto = image_service.get_dto(name)\n                image_dtos.append(dto)\n            except HTTPException:\n                # Skip images the user is not authorized to view\n                continue\n            except Exception:\n                # Skip missing images - they may have been deleted between name fetch and DTO fetch\n                continue\n\n        return image_dtos\n    except Exception:\n        raise HTTPException(status_code=500, detail=\"Failed to get image DTOs\")\n","sourceCodeStart":906,"sourceCodeEnd":925,"githubUrl":"https://github.com/invoke-ai/InvokeAI/blob/0b6a024f2ff6a86bfb953dcdb9cc504ef7397a06/invokeai/app/api/routers/images.py#L906-L925","documentation":"HTTP 500 raised by POST /images/images_by_names when resolving image names to DTOs throws outside the per-image skip logic. The endpoint intentionally skips individual missing images (deleted between fetch steps), so this error means a broader failure occurred — not a single missing image.","triggerScenarios":"POST /api/v1/images/images_by_names when the batch DTO lookup service raises (DB failure) or the outer iteration itself errors, e.g. image_dtos.append path failing on a malformed record.","commonSituations":"Very large image_names list causing query limits/timeouts; a record corrupted such that even the per-image try/except throws outside it; DB lock contention.","solutions":["Check server logs for the underlying exception","Split the name list into smaller batches","Remove suspect image names (recently deleted) and retry","Verify DB integrity; repair or restart if corrupted"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// chunk the name list before the batch lookup\nconst chunks = [];\nfor (let i = 0; i < imageNames.length; i += 50) chunks.push(imageNames.slice(i, i + 50));","typeGuard":null,"tryCatchPattern":"try {\n  const dtos = await api.getImagesByNames(names);\n} catch (e) {\n  if (e instanceof ApiError && e.status === 500) {\n    // retry per-chunk; drop names that fail to resolve\n  }\n}","preventionTips":["Chunk large name lists into small batches","Treat individual missing images as normal (server skips them)","Refresh name lists shortly before DTO lookups","Check DB integrity if failures repeat on the same names"],"tags":["http-500","api","invokeai"],"backgroundTag":"batch-image-lookup-failed","analyzedSha":"0b6a024f2ff6a86bfb953dcdb9cc504ef7397a06","analyzedAt":"2026-08-29T04:46:49.967Z","schemaVersion":2},"datasetVersion":"2026-08-29T07:17:48.351Z"}