8000 fix: add missing FileResponse import in thumbnail endpoint by tamzrod · Pull Request #113 · tamzrod/Librarian · GitHub
[go: up one dir, main page]

Skip to content

fix: add missing FileResponse import in thumbnail endpoint - #113

Merged
tamzrod merged 1 commit into
mainfrom
fix/thumbnail-fileresponse-import
Jul 7, 2026
Merged

tamzrod merged 1 commit into
mainfrom
fix/thumbnail-fileresponse-import

Conversation

@tamzrod
@tamzrod tamzrod commented Jul 7, 2026
Copy link
Copy Markdown
Owner

Summary

Fixed HTTP 500 errors when serving existing thumbnail files.

Root Cause

The get_thumbnail endpoint in api/app.py was returning HTTP 500 for existing thumbnails because FileResponse was used without being imported. This caused a NameError when trying to serve valid thumbnail files.

The bug:

  • FileResponse was referenced at line 151 but only JSONResponse and Response were imported from fastapi.responses (line 16)
  • When a thumbnail file exists on disk and the code tried to return it, Python threw: NameError: name 'FileResponse' is not defined

Fix

Added FileResponse to the import statement in api/app.py:

# Before:
from fastapi.responses import JSONResponse, Response

# After:
from fastapi.responses import JSONResponse, Response, FileResponse

Why This Wasn't Caught Earlier

  • Thumbnail generation (workers) succeeds because it doesn't import api/app.py
  • No unit/integration tests exist for the get_thumbnail endpoint
  • The bug only manifests when the endpoint is called with a request for an existing thumbnail file

Testing

Verified locally that:

  1. Before fix: NameError: name 'FileResponse' is not defined
  2. After fix: FileResponse created successfully: <class 'starlette.responses.FileResponse'>

This PR was created by an AI agent (OpenHands) on behalf of the user.

@tamzrod can click here to continue refining the PR

The get_thumbnail endpoint was returning HTTP 500 for existing thumbnails
because FileResponse was used without being imported. This caused a
NameError when trying to serve valid thumbnail files.

Root cause: FileResponse was referenced at line 151 but only JSONResponse
and Response were imported from fastapi.responses.

Fix: Add FileResponse to the import statement.
@tamzrod
tamzrod marked this pull request as ready for review July 7, 2026 23:16
@tamzrod
tamzrod merged commit 9b5eb37 into main Jul 7, 2026
3 of 7 checks passed
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.

2 participants

0