{"record":{"id":"97accd65cdbe54ce","repo":"odysseus-dev/odysseus","slug":"no-valid-attachments","errorCode":null,"errorMessage":"No valid attachments","messagePattern":"No valid attachments","errorType":"http","errorClass":"HTTPException","httpStatus":400,"severity":"error","filePath":"routes/email_routes.py","lineNumber":4181,"sourceCode":"                    return f\"{stem}-{idx + 1}{suffix}\"\n\n                with zipfile.ZipFile(buf, \"w\", compression=zipfile.ZIP_DEFLATED) as zf:\n                    for item in raw_items:\n                        if not isinstance(item, dict):\n                            continue\n                        kind = str(item.get(\"kind\") or \"\").strip().lower()\n                        item_id = str(item.get(\"id\") or \"\").strip()\n                        if kind not in {\"document\", \"gallery\"} or not item_id:\n                            continue\n                        src = _load_odysseus_attachment_source(db, kind, item_id, owner)\n                        zname = unique_name(src[\"filename\"])\n                        if \"path\" in src:\n                            zf.write(src[\"path\"], arcname=zname)\n                        else:\n                            zf.writestr(zname, src[\"content\"])\n                content = buf.getvalue()\n                if not content:\n                    raise HTTPException(status_code=400, detail=\"No valid attachments\")\n                return _stage_compose_bytes(\"odysseus-attachments.zip\", content)\n            finally:\n                db.close()\n        except HTTPException:\n            raise\n        except Exception as e:\n            logger.error(f\"Failed to stage Odysseus zip attachment: {e}\")\n            return {\"success\": False, \"error\": \"Mail operation failed\"}\n\n    @router.post(\"/compose-from-attachment/{uid}/{index}\")\n    async def compose_from_attachment(\n        uid: str,\n        index: int,\n        folder: str = Query(\"INBOX\"),\n        account_id: str | None = Query(None),\n        owner: str = Depends(require_owner),\n    ):\n        \"\"\"Stage an existing email attachment as a compose upload.","sourceCodeStart":4163,"sourceCodeEnd":4199,"githubUrl":"https://github.com/odysseus-dev/odysseus/blob/f9235ebbf13f693a6fd29ce70b097f6ec83705bf/routes/email_routes.py#L4163-L4199","documentation":"Error \"No valid attachments\" thrown in odysseus-dev/odysseus.","triggerScenarios":"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.","commonSituations":"See trigger scenarios.","solutions":["Ensure at least one attachment has a valid kind and id.","Re-select the attachments in the UI and retry."],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"f9235ebbf13f693a6fd29ce70b097f6ec83705bf","analyzedAt":"2026-08-14T21:47:48.359Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}