Skip to content

fix: handle null mime type in preview generation#58803

Open
boris324 wants to merge 1 commit into
nextcloud:masterfrom
boris324:fix/preview-null-mimetype-crash
Open

fix: handle null mime type in preview generation#58803
boris324 wants to merge 1 commit into
nextcloud:masterfrom
boris324:fix/preview-null-mimetype-crash

Conversation

@boris324

@boris324 boris324 commented Mar 9, 2026

Copy link
Copy Markdown

Fixes #58784

When generating previews for images with unusual dimensions (e.g. 18x4312 GIF), IImage::dataMimeType() can return null. This null value gets passed to Preview::setMimeType(string), causing a TypeError that crashes the entire occ preview:generate-all batch.

This adds null checks for the MIME type returned by dataMimeType() in both preview generation paths:

  • In generateProviderPreview(): skip to the next provider with a warning log
  • In generatePreview(): throw NotFoundException so the file is skipped gracefully

Both are already handled by callers, so one bad file no longer terminates the batch.

@boris324 boris324 requested a review from a team as a code owner March 9, 2026 12:03
@boris324 boris324 requested review from artonge, nfebe, salmart-dev and sorbaugh and removed request for a team March 9, 2026 12:03
@kesselb

kesselb commented Mar 9, 2026

Copy link
Copy Markdown
Contributor

Still needed after #58793?

@solracsf

solracsf commented Mar 9, 2026

Copy link
Copy Markdown
Member

Why 2 PR? Is this some AI bot? Just asking 😝
#58802

@github-actions

Copy link
Copy Markdown
Contributor

Hello there,
Thank you so much for taking the time and effort to create a pull request to our Nextcloud project.

We hope that the review process is going smooth and is helpful for you. We want to ensure your pull request is reviewed to your satisfaction. If you have a moment, our community management team would very much appreciate your feedback on your experience with this PR review process.

Your feedback is valuable to us as we continuously strive to improve our community developer experience. Please take a moment to complete our short survey by clicking on the following link: https://cloud.nextcloud.com/apps/forms/s/i9Ago4EQRZ7TWxjfmeEpPkf6

Thank you for contributing to Nextcloud and we hope to hear from you soon!

(If you believe you should not receive this message, you can add yourself to the blocklist.)

@susnux susnux added the community pull requests from community label Jun 9, 2026
@CarlSchwan

Copy link
Copy Markdown
Member

/backport to stable33

@CarlSchwan

Copy link
Copy Markdown
Member

/backport to stable34

@artonge artonge left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Blocking as https://github.com/nextcloud/server/pull/58793/changes seems to address the issue for generatePreview

@susnux susnux added this to the Nextcloud 35 milestone Jun 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: preview generation crashes on image files when generated preview has null MIME type

7 participants