invoke-ai/InvokeAI · error · HTTPException

Failed to delete video

Error message

Failed to delete video

What it means

Raised by delete_video as HTTP 500 when ApiDependencies.invoker.services.videos.delete(video_name) throws after the DTO lookup succeeded. It signals the delete operation failed at the service level (database write or filesystem removal), not that the video is missing. The endpoint deliberately surfaces this rather than returning an empty deleted_videos list with 200, which previously caused silent data-consistency failures.

Source

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

    video_name: str = PathParam(description="The name of the video to delete"),
) -> DeleteVideosResult:
    _assert_video_owner(video_name, current_user)

    # Let service-level failures surface as 500s rather than swallowing them and returning a
    # success-shaped response. A previous version of this handler caught everything and
    # returned an empty ``deleted_videos`` list with HTTP 200; the frontend treated that as
    # success, dropped the item from its cache, and the video stayed on disk — a silent
    # data-consistency failure that only became visible on the next page reload.
    try:
        video_dto = ApiDependencies.invoker.services.videos.get_dto(video_name)
    except Exception:
        raise HTTPException(status_code=404, detail="Video not found")

    board_id = video_dto.board_id or "none"
    try:
        ApiDependencies.invoker.services.videos.delete(video_name)
    except Exception:
        raise HTTPException(status_code=500, detail="Failed to delete video")

    return DeleteVideosResult(
        deleted_videos=[video_name],
        failed_videos=[],
        affected_boards=[board_id],
    )


@videos_router.post("/delete", operation_id="delete_videos_from_list", response_model=DeleteVideosResult)
def delete_videos_from_list(
    current_user: CurrentUserOrDefault,
    batch: VideoNamesBatch,
) -> DeleteVideosResult:
    # Skip — but do not re-raise — auth failures so a foreign name mid-batch doesn't
    # discard the response payload for items the caller had already legitimately deleted.
    # Without this, the client cache never learns about the partial successes and the
    # already-deleted records reappear in the UI until the next full refresh.
    #

View on GitHub (pinned to 0b6a024f2f)

Solutions

  1. Check InvokeAI server logs for the underlying exception (the handler swallows it, so logs/traceback of the service are the source).
  2. Verify the outputs/storage directory is writable and has free space (ls -ld, df -h).
  3. Check the SQLite database is not locked or corrupt; stop other InvokeAI processes and retry.
  4. Restart the InvokeAI server to release stale file handles or DB locks, then retry the delete.

Example fix

// before: ignoring the 500 leaves orphaned files
await api.deleteVideo(name).catch(() => {});
// after
try {
  await api.deleteVideo(name);
} catch (e) {
  if (e.status === 500) {
    console.error('Server-side delete failed; check server logs and disk state', e);
    throw e;
  }
}
Defensive patterns

Strategy: retry

Validate before calling

const dto = await api.getVideoDto(name); // ensures record exists before delete
deleteVideo(dto.video_name);

Try / catch

try {
  await api.deleteVideo(name);
} catch (e) {
  if (e.response?.status === 500) {
    // surface to user + verify via GET before retrying
    await verifyDeletion(name);
    throw e;
  }
  throw e;
}

Prevention

When it happens

Trigger: videos.delete() fails due to SQLite errors (locked/corrupt DB, disk full), filesystem permission errors on the video file or its directory, or the storage backend rejecting the delete while the record exists.

Common situations: Read-only or full disk; database locked by another long transaction; permission changes on the outputs directory; running InvokeAI with a misconfigured storage path after moving data dirs.

Related errors


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