Skip to content

fix(size): Skip empty image files and demote UnidentifiedImageError logging#629

Merged
trevor-e merged 1 commit into
mainfrom
seer/fix/size-image-optimization-empty-files
Jun 4, 2026
Merged

fix(size): Skip empty image files and demote UnidentifiedImageError logging#629
trevor-e merged 1 commit into
mainfrom
seer/fix/size-image-optimization-empty-files

Conversation

@sentry

@sentry sentry Bot commented Jun 4, 2026

Copy link
Copy Markdown
Contributor

This PR addresses the UnidentifiedImageError occurring in launchpad.size.insights.apple.image_optimization._analyze_image_optimization.

Problem:
The image optimization process was encountering UnidentifiedImageError when attempting to open zero-byte image files, particularly ic_tick.png and similar placeholder assets found in Flutter app bundles. The PIL.Image.open() function cannot identify the format of an empty file, leading to an error.

Root Cause:
The _analyze_image_optimization function did not include a check for zero-byte files before attempting to open them with PIL.Image.open(). While it guarded against full_path being None, it did not account for valid paths pointing to empty files. The existing except Exception block logged these as errors, causing significant Sentry noise.

Solution:

  1. Early Exit for Empty Files: Added a check if file_info.size == 0: at the beginning of _analyze_image_optimization. If a file is zero-byte, it is now logged at info level and skipped, preventing UnidentifiedImageError for the most common cases.
  2. Demote UnidentifiedImageError Logging: Explicitly caught UnidentifiedImageError and changed its logging level from exception (which creates Sentry errors) to warning. This reduces Sentry noise for any remaining edge cases where PIL cannot identify an image, without masking other critical exceptions.
  3. Import UnidentifiedImageError: Ensured UnidentifiedImageError is explicitly imported from PIL for proper handling.

Fixes LAUNCHPAD-5Y

@sentry

sentry Bot commented Jun 4, 2026

Copy link
Copy Markdown
Contributor Author

📲 Install Builds

iOS

🔗 App Name App ID Version Configuration
HackerNews com.emergetools.hackernews 3.8 (1) Release

Android

🔗 App Name App ID Version Configuration
Hacker News com.emergetools.hackernews 1.0.2 (13) Release

⚙️ launchpad-test-android Build Distribution Settings

@trevor-e trevor-e merged commit 5b43e78 into main Jun 4, 2026
25 checks passed
@trevor-e trevor-e deleted the seer/fix/size-image-optimization-empty-files branch June 4, 2026 13:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant