invoke-ai/InvokeAI · error · HTTPException

Failed to delete board after partially deleting media

Error message

Failed to delete board after partially deleting media

What it means

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.

Source

Thrown at invokeai/app/api/routers/boards.py:195

                ApiDependencies.invoker.services.board_video_records.get_all_board_video_names_for_board(
                    board_id=board_id,
                    categories=None,
                    is_intermediate=None,
                )
            )
            ApiDependencies.invoker.services.boards.delete(board_id=board_id)
            return DeleteBoardResult(
                board_id=board_id,
                deleted_board_images=deleted_board_images,
                deleted_images=[],
                deleted_board_videos=deleted_board_videos,
                deleted_videos=[],
            )
    except HTTPException:
        raise
    except Exception:
        if include_images is True:
            raise HTTPException(
                status_code=500,
                detail={
                    "message": "Failed to delete board after partially deleting media",
                    "deleted_images": deleted_images,
                    "deleted_videos": deleted_videos,
                    "board_deleted": False,
                },
            )
        raise HTTPException(status_code=500, detail="Failed to delete board")


@boards_router.get(
    "/",
    operation_id="list_boards",
    response_model=Union[OffsetPaginatedResults[BoardDTO], list[BoardDTO]],
)
def list_boards(
    current_user: CurrentUserOrDefault,

View on GitHub (pinned to 0b6a024f2f)

Solutions

  1. Inspect the response detail's deleted_images/deleted_videos lists and retry the delete for the remaining media
  2. Check server logs for the underlying exception traceback (the HTTP detail does not include it)
  3. Retry the board deletion after the transient backend issue is resolved; already-deleted items will typically be no-ops
  4. Restore DB/storage consistency manually if orphans remain (images pointing to a deleted or missing board)

Example fix

// before
deleteBoard(id, { include_images: true }); // 500 with partial state
// after
try {
  await deleteBoard(id, { include_images: true });
} catch (e) {
  const detail = e.response?.data?.detail;
  console.warn('partial delete', detail?.deleted_images, detail?.deleted_videos);
  await retryDeleteBoard(id, { include_images: true });
}
Defensive patterns

Strategy: try-catch

Validate before calling

const detail = err?.response?.data?.detail;
if (detail?.deleted_images) console.warn('Partially deleted:', detail.deleted_images, detail.deleted_videos);

Type guard

const isPartialBoardDeleteError = (e) =>
  e?.response?.status === 500 &&
  e?.response?.data?.detail?.message === 'Failed to delete board after partially deleting media';

Try / catch

try {
  await api.delete(`/boards/${boardId}`, { params: { include_images: true } });
} catch (e) {
  if (isPartialBoardDeleteError(e)) await retryBoardDelete(boardId); // idempotent retry for remainder
  else throw e;
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of invoke-ai/InvokeAI@0b6a024f2f (2026-08-29). Data as JSON: /api/errors/05d5a7aac0636780. Report an issue: GitHub.