fix(backend): guard avatar upload against a missing filename (#954)

`UploadFile.filename` can be None, and `Path(None)` raises TypeError. On the
avatar endpoint this happens before the try/except, so a filename-less upload
surfaces as an unhandled 500 instead of a clean response. Every other upload
handler already guards this with `file.filename or ""` (add_profile_sample,
transcription, generations); apply the same guard here.

Co-authored-by: Claude Opus 4.8 (1M context) <[email protected]>
This commit is contained in:
jojo
2026-07-26 23:31:48 -07:00
committed by GitHub
co-authored by Claude Opus 4.8
parent 44ef8daba3
commit 6a6f4643da
+1 -1
View File
@@ -232,7 +232,7 @@ async def upload_profile_avatar(
db: Session = Depends(get_db),
):
"""Upload or update avatar image for a profile."""
with tempfile.NamedTemporaryFile(delete=False, suffix=Path(file.filename).suffix) as tmp:
with tempfile.NamedTemporaryFile(delete=False, suffix=Path(file.filename or "").suffix) as tmp:
content = await file.read()
tmp.write(content)
tmp_path = tmp.name