invoke-ai/InvokeAI · error · HTTPException

Failed to add video to board

Error message

Failed to add video to board

What it means

HTTP 500 raised by add_video_to_board when the board_video_records service fails to add a video to a board. The handler catches every exception and re-raises as HTTPException(500, detail='Failed to add video to board'). The actual cause (missing video, missing board, DB error) is not surfaced to the client.

Source

Thrown at invokeai/app/api/routers/videos.py:898

    arg: VideoBoardArg = Body(),
) -> AddVideosToBoardResult:
    _assert_board_write_access(arg.board_id, current_user)
    _assert_video_direct_owner(arg.video_name, current_user)
    try:
        # Capture the source board BEFORE mutating so the frontend can invalidate both
        # the old and new board caches. Mirrors add_image_to_board.
        old_board_id = (
            ApiDependencies.invoker.services.board_video_records.get_board_for_video(arg.video_name) or "none"
        )
        ApiDependencies.invoker.services.board_video_records.add_video_to_board(
            board_id=arg.board_id, video_name=arg.video_name
        )
        return AddVideosToBoardResult(
            added_videos=[arg.video_name],
            affected_boards=list({arg.board_id, old_board_id}),
        )
    except Exception:
        raise HTTPException(status_code=500, detail="Failed to add video to board")


@videos_router.delete(
    "/board",
    operation_id="remove_video_from_board",
    response_model=RemoveVideosFromBoardResult,
)
def remove_video_from_board(
    current_user: CurrentUserOrDefault,
    video_name: str = Body(description="The name of the video to remove from its board", embed=True),
) -> RemoveVideosFromBoardResult:
    # A video association can be removed by EITHER the direct video owner OR a user with
    # write access to the destination board (admin, board owner, or any contributor when the
    # board is Public). This mirrors remove_image_from_board and prevents a video from being
    # stranded when a non-owner uploads into a Public board that is later made Shared/Private:
    # without the board-write fallback, neither the uploader nor the board owner could
    # detach the video. See PR #9163 review.
    old_board_id = ApiDependencies.invoker.services.board_video_records.get_board_for_video(video_name)

View on GitHub (pinned to 0b6a024f2f)

Solutions

  1. Confirm both video_name and board_id exist via the videos and boards list endpoints before calling
  2. Retry the request — transient DB lockups can trigger the generic 500
  3. Check server logs for the original exception to identify the real failure
  4. Recreate the board if it was deleted, or re-upload the video if it no longer exists

Example fix

// before
client.add_video_to_board(video_name=v, board_id=b)
// after
assert board_exists(b) and video_exists(v)
client.add_video_to_board(video_name=v, board_id=b)
Defensive patterns

Strategy: validation

Validate before calling

// ensure video and board both exist before adding
const videoOk = (await fetch(`${base}/api/v1/videos/${encodeURIComponent(videoName)}/urls`)).status !== 404;
const boardOk = (await fetch(`${base}/api/v1/boards/`)).json().then(bs => bs.some(b => b.board_id === boardId));
if (!videoOk || !boardOk) throw new Error('video or board does not exist');

Prevention

When it happens

Trigger: POST /api/v1/videos/board (add_video_to_board) with a video_name that doesn't exist, a board_id that doesn't exist, or when the board-video record insert throws.

Common situations: Stale UI state after the board was deleted; referencing a video by wrong ID; concurrent deletion of the board or video by another user; database write failure.

Related errors


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