HKUDS/DeepTutor · error · HTTPException
Attachment not found
Error message
Attachment not found
What it means
Raised by get_attachment when the requested (session_id, attachment_id) does not resolve to a stored attachment on disk — the file was deleted, the id is wrong, or the store was reset. Surfaces as HTTP 404 to the browser.
Solutions
- Verify the attachment id and URL the frontend uses match a stored upload
- Check the local attachment store directory still holds the session's files
- Handle 404 in the frontend drawer by offering re-upload or removal of the stale reference
Defensive patterns
Strategy: try-catch
When it happens
Trigger: Thrown at deeptutor/api/routers/attachments.py:66 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of HKUDS/DeepTutor@3e82f13042 (2026-08-27).
Data as JSON: /api/errors/3d96a1f95b122631.
Report an issue: GitHub.
Appendix: source
Thrown at deeptutor/api/routers/attachments.py:66
Responds with ``Content-Disposition: inline`` so browsers preview PDFs
and images directly in an ``<iframe>`` / ``<img>``. For unknown types
the browser still falls back to download, which is fine for the
drawer's "Download" button path.
"""
store = get_attachment_store()
if not isinstance(store, LocalDiskAttachmentStore):
# Future remote backends should issue a redirect to the signed URL
# here. Local-disk is the only backend today, so this branch just
# guards against an unexpected configuration.
raise HTTPException(status_code=501, detail="Attachment backend not servable")
target = store.resolve_path(
session_id=session_id,
attachment_id=attachment_id,
filename=filename,
)
if target is None:
raise HTTPException(status_code=404, detail="Attachment not found")
media_type, _ = mimetypes.guess_type(target.name)
if not media_type:
media_type = "application/octet-stream"
# ``inline`` lets the browser preview the file when possible while still
# honouring the suggested filename for the drawer's download action.
headers = {
"Content-Disposition": _content_disposition(target.name),
# User-uploaded data; do not let intermediaries cache it.
"Cache-Control": "private, max-age=0, must-revalidate",
}
return FileResponse(path=str(target), media_type=media_type, headers=headers)
View on GitHub (pinned to 3e82f13042)