Skip to content

fix(videos): return 404 when video content is not ready - #32602

Closed
Sameerlite wants to merge 2 commits into
mainfrom
litellm_video-content-not-ready-404
Closed

Sameerlite wants to merge 2 commits into
mainfrom
litellm_video-content-not-ready-404

Conversation

@Sameerlite

@Sameerlite Sameerlite commented Jul 9, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • Add raise_for_status() to sync/async video_content_handler so upstream 404s are propagated instead of returned as 200 with error JSON as video/mp4
  • Verified against live OpenAI API: GET /v1/videos/{id}/content returns 404 with "Video is not ready yet..." while status is queued/in_progress
  • Added test asserting a 404 upstream response raises with status 404 and the OpenAI error message

Before the video generation is completed
image

After the video generation is completed
image


Note

Low Risk
Small, targeted fix that only affects error handling on the video content download path; success behavior is unchanged.

Overview
Fixes a bug where sync and async video_content_handler treated upstream error responses (e.g. OpenAI 404 while a video is still queued/in_progress) as success and passed the error JSON through the content transform—so clients could see HTTP 200 with video/mp4 body containing JSON instead of the real status.

Both paths now call response.raise_for_status() after the GET/POST, matching other handlers in llm_http_handler.py, so failures flow through _handle_error and surface as BaseLLMException with the upstream status and message.

Tests cover sync and async handlers with a mocked 404 “Video is not ready yet” response.

Reviewed by Cursor Bugbot for commit 4440de8. Bugbot is set up for automated code reviews on this repo. Configure here.

OpenAI returns 404 for GET /v1/videos/{id}/content while processing;
video_content_handler was ignoring non-2xx responses and the proxy
returned 200 with the error JSON as video/mp4.

Co-authored-by: Cursor <cursoragent@cursor.com>
@greptile-apps

greptile-apps Bot commented Jul 9, 2026 •

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR fixes a bug where the sync and async video_content_handler methods would silently swallow upstream HTTP error responses (e.g., a 404 while a video is still processing) and forward the error JSON body as if it were valid video/mp4 content, causing clients to receive HTTP 200 with garbage data.

  • Adds response.raise_for_status() to both the sync and async video content handler paths, consistent with the pattern used by other handlers in llm_http_handler.py; errors now propagate through the existing _handle_error → BaseLLMException path with the correct upstream status code.
  • Adds two new fully-mocked tests covering the sync and async 404-propagation scenarios, satisfying the tests/test_litellm folder's mock-only requirement.

Confidence Score: 5/5

  • This PR is safe to merge. It is a minimal, targeted two-line addition in each handler that only activates on error responses; the success path is completely unchanged.
  • Both sync and async changes follow the established pattern used throughout llm_http_handler.py. The httpx.HTTPStatusError raised by raise_for_status() is already handled by _handle_error's explicit isinstance(e, httpx.HTTPStatusError) branch, so the error-to-exception translation is robust. New tests cover both paths with properly constructed mock responses that exercise the real raise_for_status() code path.
  • No files require special attention.

Important Files Changed

Filename Overview
litellm/llms/custom_httpx/llm_http_handler.py Adds response.raise_for_status() to both sync video_content_handler and async async_video_content_handler before response transformation, matching the pattern used by other handlers in this file. The httpx.HTTPStatusError is caught by the existing except Exception block and routed through _handle_error, which already handles httpx.HTTPStatusError specifically at line 5549.
tests/test_litellm/test_video_generation.py Adds two new mock-only tests for sync and async 404-propagation paths. Tests use httpx.Response with a real 404 status and JSON body, which correctly triggers raise_for_status() and exercises the full error path through _handle_error. No real network calls are made.

Reviews (3): Last reviewed commit: "test(videos): cover async video content ..." | Re-trigger Greptile

Mirror the sync not-ready test for async_video_content_handler.

Co-authored-by: Cursor <cursoragent@cursor.com>
@Sameerlite

Copy link
Copy Markdown
Contributor Author

@greptileai

@Sameerlite

Copy link
Copy Markdown
Contributor Author

bugbot run

@cursor cursor Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Bugbot reviewed your changes and found no new issues!

Comment @cursor review or bugbot run to trigger another review on this PR

Reviewed by Cursor Bugbot for commit 4440de8. Configure here.

@codecov

codecov Bot commented Jul 9, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@codspeed

codspeed Bot commented Jul 9, 2026 •

Copy link
Copy Markdown
Contributor

Merging this PR will not alter performance

✅ 31 untouched benchmarks


Comparing litellm_video-content-not-ready-404 (4440de8) with litellm_internal_staging (f6b9518)

Open in CodSpeed

@Sameerlite Sameerlite closed this Jul 15, 2026
@Sameerlite Sameerlite reopened this Aug 10, 2026
@yuneng-berri
yuneng-berri deleted the branch main September 13, 2026 04:29
@yuneng-berri yuneng-berri reopened this Sep 13, 2026
@devin-ai-integration
devin-ai-integration Bot changed the base branch from litellm_internal_staging to main September 23, 2026 15:47
@devin-ai-integration
devin-ai-integration Bot requested a review from a team September 23, 2026 15:47
@CLAassistant

CLAassistant commented Nov 5, 2026 •

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@mateo-berri

Copy link
Copy Markdown
Contributor

#43787 made video content downloads raise the upstream error, so a video that is not ready now returns a 404. Reopen if something is missing

@mateo-berri mateo-berri closed this Nov 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants