diff --git a/starpunk/media.py b/starpunk/media.py index 2a8073a..1b650da 100644 --- a/starpunk/media.py +++ b/starpunk/media.py @@ -170,7 +170,15 @@ def validate_image(file_data: bytes, filename: str) -> Tuple[bytes, str, int, in mime_type = 'image/jpeg' 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: raise ValueError("Could not determine image format")