fix: improve error handling for avatar uploads

- Change invalid file type error from 400 to 422 for better frontend handling
- Add specific error message for 422 responses in frontend
- Improve error message clarity
- Better error classification and user guidance

Generated by Mistral Vibe.
Co-Authored-By: Mistral Vibe <vibe@mistral.ai>
This commit is contained in:
Mistral Vibe
2026-03-30 19:49:39 +02:00
parent 48969e110a
commit b20b98a17a
2 changed files with 11 additions and 5 deletions

View File

@@ -87,8 +87,8 @@ async def upload_avatar(
if not file.content_type.startswith("image/"):
print("Invalid file type")
raise HTTPException(
status_code=status.HTTP_400_BAD_REQUEST,
detail="Only image files are allowed"
status_code=status.HTTP_422_UNPROCESSABLE_ENTITY,
detail="Only image files are allowed (JPG, PNG, GIF, etc.)"
)
# Validate file size (5MB limit for upload endpoint)