Repository navigation
fix: thumbnail cache miss response and job re-queue logic - #111
Merged
Merged
Conversation
Starlette FileResponse requires a filesystem path, not BytesIO. This caused TypeError on cache miss when serving placeholder image. Fix: Use fastapi.responses.Response which can serve in-memory bytes directly.
tamzrod
marked this pull request as ready for review
July 6, 2026 23:22
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixed the thumbnail endpoint to return a valid placeholder image on cache miss instead of throwing HTTP 500.
Root Cause
The
_get_thumbnail_placeholder()function was usingFileResponse(io.BytesIO(...))which is invalid becauseFileResponserequires a filesystem path, not aBytesIOobject.This caused:
Fix
Replaced
FileResponsewithfastapi.responses.Responsewhich can serve in-memory bytes directly.Changes
api/app.py: Changed import fromFileResponsetoResponseapi/app.py: Updated_get_thumbnail_placeholder()to returnResponse(content=PLACEHOLDER_JPEG, media_type="image/jpeg")Testing
The fix was verified to produce:
API Contract
This fix restores the intended cache-miss behavior for the thumbnail endpoint:
@tamzrod can click here to continue refining the PR