Skip to content

Prevent animated WebP conversion failures#487

Merged
rob93c merged 4 commits intomainfrom
handle-animated-webp
Apr 4, 2026
Merged

Prevent animated WebP conversion failures#487
rob93c merged 4 commits intomainfrom
handle-animated-webp

Conversation

@rob93c
Copy link
Copy Markdown
Member

@rob93c rob93c commented Apr 4, 2026

Summary by CodeRabbit

  • Bug Fixes
    • Animated WebP images are now explicitly detected and reported as unsupported, returning a clearer, specific error message when conversion isn't attempted.
  • Tests
    • Updated test expectations to validate the new unsupported-WebP error message for animated WebP cases.

@rob93c rob93c requested a review from MartelliEnrico April 4, 2026 14:50
@rob93c rob93c self-assigned this Apr 4, 2026
@rob93c rob93c added enhancement New feature or request unit test This marks issues revolving around unit tests labels Apr 4, 2026
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Apr 4, 2026

Warning

Rate limit exceeded

@rob93c has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 0 minutes and 34 seconds before requesting another review.

Your organization is not enrolled in usage-based pricing. Contact your admin to enable usage-based pricing to continue reviews beyond the rate limit, or try again in 0 minutes and 34 seconds.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: ce73e968-89a1-4e83-8528-1904fe5800fa

📥 Commits

Reviewing files that changed from the base of the PR and between 63c85c1 and f7b5930.

📒 Files selected for processing (1)
  • src/main/java/com/github/stickerifier/stickerify/media/MediaHelper.java
📝 Walkthrough

Walkthrough

MediaHelper now treats animated WebP as unsupported by detecting animation in the WebP header and excluding such files from the image conversion/compliance path; animated WebP files will fall through to the unsupported MIME-type error.

Changes

Cohort / File(s) Summary
WebP animation & image support
src/main/java/com/github/stickerifier/stickerify/media/MediaHelper.java
Added isAnimatedWebp(File) to detect animation from WebP headers, added isSupportedImage(File, String) to special-case image/webp, and updated convert(File) to use the new predicate so animated WebP is rejected from the image conversion branch.
Test expectation update
src/test/java/com/github/stickerifier/stickerify/media/MediaHelperTest.java
Updated resizeAnimatedWebpVideo test to expect the new error message "The file with image/webp MIME type is not supported" when attempting to convert an animated WebP.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related issues

Possibly related PRs

Suggested reviewers

  • MartelliEnrico

Poem

🐰 I nibbled bytes and scoped the frame,
Found ANIM flags and called its name.
"Not an image" I softly said,
So onward it went — a different thread. ✨

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 66.67% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately reflects the main change: implementing animated WebP detection to prevent conversion failures by treating animated WebP as unsupported rather than processing it through the image conversion path.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@src/main/java/com/github/stickerifier/stickerify/media/MediaHelper.java`:
- Around line 299-327: The animated WebP detection in isAnimatedWebp should
parse the WebP RIFF/VP8X structure instead of substring searching; replace the
current byte-scan logic with a short structured read: open the file
(isAnimatedWebp), read at least the first 21 bytes (more if you want safety),
verify bytes 0-3 == "RIFF" and bytes 8-11 == "WEBP", check if the chunk tag at
bytes 12-15 equals "VP8X", and if so read the flags byte at offset 20 and return
((flags & 0x02) != 0) to indicate animation; if VP8X is absent, return false
(static). Update isAnimatedWebp to log/propagate IO errors consistently and use
the above checks so isSupportedImage correctly filters animated WebP via
isAnimatedWebp.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 99b0c8b8-d531-4087-9353-1acb85e7e9e8

📥 Commits

Reviewing files that changed from the base of the PR and between e8e4d08 and 88272f7.

📒 Files selected for processing (2)
  • src/main/java/com/github/stickerifier/stickerify/media/MediaHelper.java
  • src/test/java/com/github/stickerifier/stickerify/media/MediaHelperTest.java

coderabbitai[bot]
coderabbitai bot previously approved these changes Apr 4, 2026
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@src/main/java/com/github/stickerifier/stickerify/media/MediaHelper.java`:
- Around line 321-325: In isAnimatedWebp, avoid using
FileInputStream.read(header) which can return a partial read; instead use
FileInputStream.readNBytes(...) to read the fixed-length header (size
WEBP_FLAGS_BYTE_OFFSET + 1) and verify you received the exact number of bytes
before proceeding (i.e., check the returned byte array length equals the
expected header length) so the subsequent checks against WEBP_FLAGS_BYTE_OFFSET
and WebP flags are not performed on partial data.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: e1bf30d3-4c73-488b-99bc-a1b74d832fe6

📥 Commits

Reviewing files that changed from the base of the PR and between 3d9ac17 and 63c85c1.

📒 Files selected for processing (1)
  • src/main/java/com/github/stickerifier/stickerify/media/MediaHelper.java

coderabbitai[bot]
coderabbitai bot previously approved these changes Apr 4, 2026
Copy link
Copy Markdown
Contributor

@MartelliEnrico MartelliEnrico left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@rob93c rob93c merged commit 6d0599d into main Apr 4, 2026
8 checks passed
@rob93c rob93c deleted the handle-animated-webp branch April 4, 2026 17:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request unit test This marks issues revolving around unit tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants