{"record":{"id":"0149966610c3f69f","repo":"invoke-ai/InvokeAI","slug":"failed-to-delete-images","errorCode":null,"errorMessage":"Failed to delete images","messagePattern":"Failed to delete images","errorType":"http","errorClass":"HTTPException","httpStatus":500,"severity":"error","filePath":"invokeai/app/api/routers/images.py","lineNumber":606,"sourceCode":"                # would answer for names the caller was never entitled to touch.\n                #\n                # This is narrow only because image_records.get() no longer translates a\n                # sqlite3.Error into this exception — see the comment there. If that\n                # translation ever comes back, a locked or corrupt database would land here\n                # and a whole failed batch would answer 200 with empty result lists.\n            except Exception:\n                # A genuine deletion failure (not an auth/404 skip) — report it so the\n                # client can surface a partial-failure warning, matching the video path.\n                failed_images.add(image_name)\n        return DeleteImagesResult(\n            deleted_images=list(deleted_images),\n            failed_images=list(failed_images),\n            affected_boards=list(affected_boards),\n        )\n    except HTTPException:\n        raise\n    except Exception:\n        raise HTTPException(status_code=500, detail=\"Failed to delete images\")\n\n\n@images_router.delete(\"/uncategorized\", operation_id=\"delete_uncategorized_images\", response_model=DeleteImagesResult)\ndef delete_uncategorized_images(\n    current_user: CurrentUserOrDefault,\n) -> DeleteImagesResult:\n    \"\"\"Deletes all uncategorized images owned by the current user (or all if admin)\"\"\"\n    assert_image_move_maintenance_inactive()\n\n    image_names = ApiDependencies.invoker.services.board_images.get_all_board_image_names_for_board(\n        board_id=\"none\", categories=None, is_intermediate=None\n    )\n\n    try:\n        deleted_images: set[str] = set()\n        failed_images: set[str] = set()\n        affected_boards: set[str] = set()\n        for image_name in image_names:","sourceCodeStart":588,"sourceCodeEnd":624,"githubUrl":"https://github.com/invoke-ai/InvokeAI/blob/0b6a024f2ff6a86bfb953dcdb9cc504ef7397a06/invokeai/app/api/routers/images.py#L588-L624","documentation":"HTTP 500 raised by POST /images/delete when the bulk deletion service call throws an unexpected (non-HTTPException) error. Successful but partial deletions are reported in the DeleteImagesResult payload instead of raising, so this error means the operation crashed outright.","triggerScenarios":"DELETE /api/v1/images/delete when the images service raises while deleting the listed image_names — e.g. storage layer failure, database error, or corrupted image records.","commonSituations":"Image files on disk already removed manually so record deletion fails; sqlite DB locked by another process; deleting many images triggers a storage backend timeout.","solutions":["Inspect server logs for the underlying exception","Retry the delete with a smaller batch of image_names","Verify image files and database are present and writable","Restore missing files or clean orphaned DB records before retrying"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// confirm images still exist before bulk delete\nconst existing = await api.getImageDtos(imageNames);\nif (existing.length !== imageNames.length) {\n  imageNames = existing.map(i => i.image_name);\n}","typeGuard":null,"tryCatchPattern":"try {\n  const res = await api.deleteImagesFromList(imageNames);\n  // inspect res.failed_images for partial failures\n} catch (e) {\n  if (e instanceof ApiError && e.status === 500) {\n    // retry in smaller batches; check server logs\n  }\n}","preventionTips":["Delete in small batches to avoid timeouts","Never delete image files on disk manually while the app runs","Check failed_images in successful responses before assuming all deleted","Avoid deleting during active generation jobs"],"tags":["http-500","api","invokeai"],"backgroundTag":"bulk-delete-failed","analyzedSha":"0b6a024f2ff6a86bfb953dcdb9cc504ef7397a06","analyzedAt":"2026-08-29T04:46:49.967Z","schemaVersion":2},"datasetVersion":"2026-08-29T07:17:48.351Z"}