invoke-ai/InvokeAI · error · HTTPException
Video file not found
Error message
Video file not found
What it means
Raised by get_video_full as HTTP 404 when open(path_str, 'rb') raises OSError after the path was resolved. The record exists but the file on disk is gone or unreadable — a DB/filesystem mismatch. The code opens the fd once (rather than letting FileResponse lazily open by path) precisely to avoid racing with concurrent deletes; this 404 is the controlled outcome when the open still fails.
Source
Thrown at invokeai/app/api/routers/videos.py:616
Browser media requests authenticate with the path-scoped HttpOnly cookie set at login.
"""
_assert_video_read_access(video_name, current_user)
try:
path_str = ApiDependencies.invoker.services.videos.get_path(video_name, thumbnail=False)
except Exception:
raise HTTPException(status_code=404)
# Open once and serve every branch from the fd. Deletion stages files away via an
# atomic rename, so any later path-based stat/open — including FileResponse's lazy
# open after the route returns — races with a concurrent delete and surfaces as an
# uncontrolled 500. An open fd is immune: the data stays readable until the handle
# closes, even after the path is gone.
video_file: Optional[BinaryIO] = None
try:
video_file = open(path_str, "rb")
except OSError:
raise HTTPException(status_code=404)
try:
file_size = os.fstat(video_file.fileno()).st_size
range_header = request.headers.get("range") or request.headers.get("Range")
common_headers = {
"Accept-Ranges": "bytes",
"Cache-Control": _get_video_cache_control(),
"Content-Disposition": f'inline; filename="{video_name}"',
}
# HEAD: respond with metadata only.
if request.method == "HEAD":
return Response(
status_code=200,
media_type="video/mp4",
headers={**common_headers, "Content-Length": str(file_size)},
)View on GitHub (pinned to 0b6a024f2f)
Solutions
- Check that the file at the resolved path exists and is readable (ls -l, stat).
- Delete the orphaned record via the API so DB and disk stay consistent, then re-upload/re-generate.
- Fix permissions or remount the outputs directory if the OSError is permission/device related.
- Inspect server logs for the exact OSError errno to distinguish missing-file from I/O errors.
Defensive patterns
Strategy: fallback
Try / catch
try {
const res = await fetch(mediaUrl, { headers });
if (!res.ok && res.status === 404) {
showPlaceholder(); // record exists but file missing — DB/disk mismatch
}
} catch (e) {
showPlaceholder();
} Prevention
- Never delete files directly from the outputs directory — use the API so records stay consistent.
- Monitor disk/mount health; read-only mounts surface as this 404.
- On 404 for an existing DTO, reconcile by deleting the orphaned record server-side.
When it happens
Trigger: open() fails with FileNotFoundError (file deleted/moved), PermissionError, or EACCES/EIO on the resolved video path; outputs dir partially deleted or on a failed mount.
Common situations: Manual cleanup of the outputs folder while records remain; moving/reinstalling InvokeAI without migrating files; read-only mounts; antivirus or backup tools locking/removing files mid-read.
Understand the failure class
Background: "File not found" and ENOENT errors: why libraries can't find a file that should exist — this error's family across 50 libraries.
Related errors
- Failed to delete video
- Video record not found
- Video metadata not found
- Video workflow not found
- Video thumbnail not found
AI-assisted analysis of invoke-ai/InvokeAI@0b6a024f2f (2026-08-29).
Data as JSON: /api/errors/ac7a2af01fe58b17.
Report an issue: GitHub.