From f767c8e0582fd2c26bb20d7fde86f5739dc82ffa Mon Sep 17 00:00:00 2001 From: jojo <49631805+joj0hq@users.noreply.github.com> Date: Mon, 27 Jul 2026 16:31:48 +1000 Subject: [PATCH] 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) --- backend/routes/profiles.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/backend/routes/profiles.py b/backend/routes/profiles.py index 054fe4aa..429572f1 100644 --- a/backend/routes/profiles.py +++ b/backend/routes/profiles.py @@ -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