odysseus-dev/odysseus · error · HTTPException

No valid attachments

Error message

No valid attachments

What it means

Guard in compose_from_odysseus_zip: after filtering the requested items, none resolved to a valid, storable attachment (wrong kind, missing id, or load failures). Rather than emitting an empty zip, the endpoint rejects with 404 so the client can correct the selection.

Solutions

  1. Ensure at least one attachment has a valid kind and id.
  2. Re-select the attachments in the UI and retry.
Defensive patterns

Strategy: validation

When it happens

Trigger: Triggered when the corresponding server-side validation or runtime check at the recorded location rejects the request or operation and returns this error message to the caller.

Common situations: See trigger scenarios.


AI-assisted analysis of odysseus-dev/odysseus@f9235ebbf1 (2026-08-14). Data as JSON: /api/errors/97accd65cdbe54ce. Report an issue: GitHub.

Appendix: source

Thrown at routes/email_routes.py:4181

                    return f"{stem}-{idx + 1}{suffix}"

                with zipfile.ZipFile(buf, "w", compression=zipfile.ZIP_DEFLATED) as zf:
                    for item in raw_items:
                        if not isinstance(item, dict):
                            continue
                        kind = str(item.get("kind") or "").strip().lower()
                        item_id = str(item.get("id") or "").strip()
                        if kind not in {"document", "gallery"} or not item_id:
                            continue
                        src = _load_odysseus_attachment_source(db, kind, item_id, owner)
                        zname = unique_name(src["filename"])
                        if "path" in src:
                            zf.write(src["path"], arcname=zname)
                        else:
                            zf.writestr(zname, src["content"])
                content = buf.getvalue()
                if not content:
                    raise HTTPException(status_code=400, detail="No valid attachments")
                return _stage_compose_bytes("odysseus-attachments.zip", content)
            finally:
                db.close()
        except HTTPException:
            raise
        except Exception as e:
            logger.error(f"Failed to stage Odysseus zip attachment: {e}")
            return {"success": False, "error": "Mail operation failed"}

    @router.post("/compose-from-attachment/{uid}/{index}")
    async def compose_from_attachment(
        uid: str,
        index: int,
        folder: str = Query("INBOX"),
        account_id: str | None = Query(None),
        owner: str = Depends(require_owner),
    ):
        """Stage an existing email attachment as a compose upload.

View on GitHub (pinned to f9235ebbf1)