{"record":{"id":"05d5a7aac0636780","repo":"invoke-ai/InvokeAI","slug":"failed-to-delete-board-after-partially-deleting-me","errorCode":null,"errorMessage":"Failed to delete board after partially deleting media","messagePattern":"Failed to delete board after partially deleting media","errorType":"http","errorClass":"HTTPException","httpStatus":500,"severity":"error","filePath":"invokeai/app/api/routers/boards.py","lineNumber":195,"sourceCode":"                ApiDependencies.invoker.services.board_video_records.get_all_board_video_names_for_board(\n                    board_id=board_id,\n                    categories=None,\n                    is_intermediate=None,\n                )\n            )\n            ApiDependencies.invoker.services.boards.delete(board_id=board_id)\n            return DeleteBoardResult(\n                board_id=board_id,\n                deleted_board_images=deleted_board_images,\n                deleted_images=[],\n                deleted_board_videos=deleted_board_videos,\n                deleted_videos=[],\n            )\n    except HTTPException:\n        raise\n    except Exception:\n        if include_images is True:\n            raise HTTPException(\n                status_code=500,\n                detail={\n                    \"message\": \"Failed to delete board after partially deleting media\",\n                    \"deleted_images\": deleted_images,\n                    \"deleted_videos\": deleted_videos,\n                    \"board_deleted\": False,\n                },\n            )\n        raise HTTPException(status_code=500, detail=\"Failed to delete board\")\n\n\n@boards_router.get(\n    \"/\",\n    operation_id=\"list_boards\",\n    response_model=Union[OffsetPaginatedResults[BoardDTO], list[BoardDTO]],\n)\ndef list_boards(\n    current_user: CurrentUserOrDefault,","sourceCodeStart":177,"sourceCodeEnd":213,"githubUrl":"https://github.com/invoke-ai/InvokeAI/blob/0b6a024f2ff6a86bfb953dcdb9cc504ef7397a06/invokeai/app/api/routers/boards.py#L177-L213","documentation":"HTTP 500 raised by delete_board when media deletion partially succeeded (some images/videos were already removed) but an unexpected exception occurred before the board itself was deleted. It wraps the partial failure with a detail object reporting deleted_images, deleted_videos and board_deleted=false.","triggerScenarios":"During a DELETE board call with include_images=true, the board/media service throws a non-HTTPException after some delete_image/delete_video calls already succeeded.","commonSituations":"Database lock or connection drop mid-transaction; storage backend (file/blob) I/O failure while deleting media files; a bug in the board_images/board_images service for one specific media item.","solutions":["Inspect the response detail's deleted_images/deleted_videos lists and retry the delete for the remaining media","Check server logs for the underlying exception traceback (the HTTP detail does not include it)","Retry the board deletion after the transient backend issue is resolved; already-deleted items will typically be no-ops","Restore DB/storage consistency manually if orphans remain (images pointing to a deleted or missing board)"],"exampleFix":"// before\ndeleteBoard(id, { include_images: true }); // 500 with partial state\n// after\ntry {\n  await deleteBoard(id, { include_images: true });\n} catch (e) {\n  const detail = e.response?.data?.detail;\n  console.warn('partial delete', detail?.deleted_images, detail?.deleted_videos);\n  await retryDeleteBoard(id, { include_images: true });\n}","handlingStrategy":"try-catch","validationCode":"const detail = err?.response?.data?.detail;\nif (detail?.deleted_images) console.warn('Partially deleted:', detail.deleted_images, detail.deleted_videos);","typeGuard":"const isPartialBoardDeleteError = (e) =>\n  e?.response?.status === 500 &&\n  e?.response?.data?.detail?.message === 'Failed to delete board after partially deleting media';","tryCatchPattern":"try {\n  await api.delete(`/boards/${boardId}`, { params: { include_images: true } });\n} catch (e) {\n  if (isPartialBoardDeleteError(e)) await retryBoardDelete(boardId); // idempotent retry for remainder\n  else throw e;\n}","preventionTips":["Ensure stable DB/storage connectivity during board deletions","Read detail.deleted_images/deleted_videos to reconcile partial state before retrying","Back up the database before bulk board cleanup operations"],"tags":["http-500","partial-failure","boards","consistency"],"backgroundTag":"partial-deletion-failure","analyzedSha":"0b6a024f2ff6a86bfb953dcdb9cc504ef7397a06","analyzedAt":"2026-08-29T04:46:49.967Z","schemaVersion":2},"datasetVersion":"2026-08-29T07:17:48.351Z"}