HKUDS/DeepTutor · error · HTTPException

Attachment backend not servable

Error message

Attachment backend not servable

What it means

Raised by the GET attachment endpoint when the configured attachment store is not a LocalDiskAttachmentStore. Today local disk is the only servable backend; this guard (HTTP 501) blocks serving until a future remote backend issues signed-URL redirects.

Solutions

  1. Configure the attachment store back to LocalDiskAttachmentStore
  2. If a remote backend is intended, implement the signed-URL redirect path in get_attachment
  3. Return 501 to the client with an explanatory message until remote serving exists
Defensive patterns

Strategy: type-guard

When it happens

Trigger: Thrown at deeptutor/api/routers/attachments.py:58 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/b54c8420fd814452. Report an issue: GitHub.

Appendix: source

Thrown at deeptutor/api/routers/attachments.py:58

@router.get("/{session_id}/{attachment_id}/{filename:path}")
async def get_attachment(
    session_id: str,
    attachment_id: str,
    filename: str,
):
    """Serve a previously uploaded chat attachment.

    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.

View on GitHub (pinned to 3e82f13042)