{"record":{"id":"c6aa4c3120716cdd","repo":"invoke-ai/InvokeAI","slug":"failed-to-remove-image-from-board","errorCode":null,"errorMessage":"Failed to remove image from board","messagePattern":"Failed to remove image from board","errorType":"http","errorClass":"HTTPException","httpStatus":500,"severity":"error","filePath":"invokeai/app/api/routers/board_images.py","lineNumber":226,"sourceCode":"            outcome = _remove_from_board_and_classify(image_name, old_board_id)\n            if outcome is _ScopedRemoveOutcome.REMOVED:\n                removed_images.add(image_name)\n                affected_boards.add(\"none\")\n                affected_boards.add(old_board_id)\n            elif outcome is _ScopedRemoveOutcome.MOVED:\n                failed_images.add(image_name)\n            # GONE lands in neither list, matching the batch route's treatment of a name that\n            # vanished mid-flight; the client's refetches surface the deletion.\n        return RemoveImagesFromBoardResult(\n            removed_images=list(removed_images),\n            failed_images=list(failed_images),\n            affected_boards=list(affected_boards),\n        )\n\n    except HTTPException:\n        raise\n    except Exception:\n        raise HTTPException(status_code=500, detail=\"Failed to remove image from board\")\n\n\n@board_images_router.post(\n    \"/batch\",\n    operation_id=\"add_images_to_board\",\n    responses={\n        201: {\"description\": \"Images were added to board successfully\"},\n    },\n    status_code=201,\n    response_model=AddImagesToBoardResult,\n)\ndef add_images_to_board(\n    current_user: CurrentUserOrDefault,\n    board_id: str = Body(description=\"The id of the board to add to\"),\n    image_names: list[ImageName] = Body(\n        description=\"The names of the images to add\", embed=True, max_length=MAX_IMAGE_BATCH_SIZE\n    ),\n) -> AddImagesToBoardResult:","sourceCodeStart":208,"sourceCodeEnd":244,"githubUrl":"https://github.com/invoke-ai/InvokeAI/blob/0b6a024f2ff6a86bfb953dcdb9cc504ef7397a06/invokeai/app/api/routers/board_images.py#L208-L244","documentation":"HTTP 500 raised by the DELETE /board_images/ endpoint when an unexpected exception escapes the board-image removal flow. The API wraps all non-HTTP exceptions from ApiDependencies.invoker.services.board_images.remove_image_from_board into a generic 500, so the real cause (DB error, service crash) is hidden in server logs.","triggerScenarios":"DELETE /board_images/{image_name}/{board_id} where the image service throws while deleting the board-image association row — e.g. SQLite/Postgres connection failure, image_name not found mid-delete, or an internal service exception other than a known HTTPException.","commonSituations":"Database locked/corrupted SQLite file, stale image_name after gallery pruning, concurrent deletion of the same image, or an InvokeAI service dependency not initialized (rare misconfigured install).","solutions":["Check the server terminal logs for the underlying exception printed just before this 500","Verify the image_name exists (GET the image or list board images) before deleting","Confirm the database file/connection is healthy (permissions on invokeai.db, Postgres reachable)","Retry the delete; if the image was already removed, the failure is benign","Upgrade InvokeAI — several board_images race-condition bugs were fixed in later releases"],"exampleFix":"// before\nawait axios.delete(`/board_images/${imageName}/${boardId}`);\n// after\ntry {\n  await axios.delete(`/board_images/${imageName}/${boardId}`);\n} catch (e) {\n  if (e.response?.status === 500) console.error('check server logs for underlying cause', imageName);\n  throw e;\n}","handlingStrategy":"try-catch","validationCode":"const img = await api.get(`/images/${imageName}/metadata`).catch(() => null);\nif (!img) console.warn('image already gone; skip removal');","typeGuard":"const isHttpError = (e) => e && typeof e === 'object' && 'response' in e && e.response?.status !== undefined;","tryCatchPattern":"try {\n  await api.delete(`/board_images/${imageName}/${boardId}`);\n} catch (e) {\n  if (e.response?.status === 500) {\n    console.error('remove_image failed; inspect server logs for root cause', { imageName, boardId });\n  }\n  throw e;\n}","preventionTips":["Verify image_name exists before removing","Make deletes idempotent so double-removal is harmless","Watch InvokeAI server logs, not just client errors","Keep the database file healthy and backed up","Pin a recent InvokeAI version to get board_images race fixes"],"tags":["http-500","api","database","invokeai"],"backgroundTag":"unexpected-internal-server-error","analyzedSha":"0b6a024f2ff6a86bfb953dcdb9cc504ef7397a06","analyzedAt":"2026-08-29T04:46:49.967Z","schemaVersion":2},"datasetVersion":"2026-08-29T07:17:48.351Z"}