chore: Add format detection logging for debugging

Logs the detected image format when a file is rejected to help
diagnose why iPhone uploads are being rejected.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
2025-12-16 18:14:05 -07:00
parent 042505d5a6
commit 25b8cbd79d

View File

@@ -170,7 +170,15 @@ def validate_image(file_data: bytes, filename: str) -> Tuple[bytes, str, int, in
mime_type = 'image/jpeg' mime_type = 'image/jpeg'
if mime_type not in ALLOWED_MIME_TYPES: if mime_type not in ALLOWED_MIME_TYPES:
raise ValueError(f"Invalid image format. Accepted: JPEG, PNG, GIF, WebP") # Log the detected format for debugging (v1.4.2)
try:
current_app.logger.warning(
f'Media upload rejected format: filename="{filename}", '
f'detected_format="{img.format}", mime_type="{mime_type}"'
)
except RuntimeError:
pass # Outside app context
raise ValueError(f"Invalid image format '{img.format}'. Accepted: JPEG, PNG, GIF, WebP")
else: else:
raise ValueError("Could not determine image format") raise ValueError("Could not determine image format")