{"record":{"id":"d7a5aaa3d7096971","repo":"invoke-ai/InvokeAI","slug":"failed-to-add-video-to-board","errorCode":null,"errorMessage":"Failed to add video to board","messagePattern":"Failed to add video to board","errorType":"http","errorClass":"HTTPException","httpStatus":500,"severity":"error","filePath":"invokeai/app/api/routers/videos.py","lineNumber":898,"sourceCode":"    arg: VideoBoardArg = Body(),\n) -> AddVideosToBoardResult:\n    _assert_board_write_access(arg.board_id, current_user)\n    _assert_video_direct_owner(arg.video_name, current_user)\n    try:\n        # Capture the source board BEFORE mutating so the frontend can invalidate both\n        # the old and new board caches. Mirrors add_image_to_board.\n        old_board_id = (\n            ApiDependencies.invoker.services.board_video_records.get_board_for_video(arg.video_name) or \"none\"\n        )\n        ApiDependencies.invoker.services.board_video_records.add_video_to_board(\n            board_id=arg.board_id, video_name=arg.video_name\n        )\n        return AddVideosToBoardResult(\n            added_videos=[arg.video_name],\n            affected_boards=list({arg.board_id, old_board_id}),\n        )\n    except Exception:\n        raise HTTPException(status_code=500, detail=\"Failed to add video to board\")\n\n\n@videos_router.delete(\n    \"/board\",\n    operation_id=\"remove_video_from_board\",\n    response_model=RemoveVideosFromBoardResult,\n)\ndef remove_video_from_board(\n    current_user: CurrentUserOrDefault,\n    video_name: str = Body(description=\"The name of the video to remove from its board\", embed=True),\n) -> RemoveVideosFromBoardResult:\n    # A video association can be removed by EITHER the direct video owner OR a user with\n    # write access to the destination board (admin, board owner, or any contributor when the\n    # board is Public). This mirrors remove_image_from_board and prevents a video from being\n    # stranded when a non-owner uploads into a Public board that is later made Shared/Private:\n    # without the board-write fallback, neither the uploader nor the board owner could\n    # detach the video. See PR #9163 review.\n    old_board_id = ApiDependencies.invoker.services.board_video_records.get_board_for_video(video_name)","sourceCodeStart":880,"sourceCodeEnd":916,"githubUrl":"https://github.com/invoke-ai/InvokeAI/blob/0b6a024f2ff6a86bfb953dcdb9cc504ef7397a06/invokeai/app/api/routers/videos.py#L880-L916","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Confirm both video_name and board_id exist via the videos and boards list endpoints before calling","Retry the request — transient DB lockups can trigger the generic 500","Check server logs for the original exception to identify the real failure","Recreate the board if it was deleted, or re-upload the video if it no longer exists"],"exampleFix":"// before\nclient.add_video_to_board(video_name=v, board_id=b)\n// after\nassert board_exists(b) and video_exists(v)\nclient.add_video_to_board(video_name=v, board_id=b)","handlingStrategy":"validation","validationCode":"// ensure video and board both exist before adding\nconst videoOk = (await fetch(`${base}/api/v1/videos/${encodeURIComponent(videoName)}/urls`)).status !== 404;\nconst boardOk = (await fetch(`${base}/api/v1/boards/`)).json().then(bs => bs.some(b => b.board_id === boardId));\nif (!videoOk || !boardOk) throw new Error('video or board does not exist');","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Refresh board/video state in the UI before mutation calls","Handle concurrent deletions by re-validating after a 500","Watch server logs for the underlying exception when this 500 fires"],"tags":["http-500","rest-api","boards","invokeai"],"backgroundTag":"internal-server-error-500","analyzedSha":"0b6a024f2ff6a86bfb953dcdb9cc504ef7397a06","analyzedAt":"2026-08-29T04:46:49.967Z","schemaVersion":2},"datasetVersion":"2026-08-29T07:17:48.351Z"}