Skip to content

fix: handle null mime type in preview generation#58803

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

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

Conversation

@boris324
Copy link

@boris324 boris324 commented Mar 9, 2026

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
Copy link
Contributor

kesselb commented Mar 9, 2026

Still needed after #58793?

@solracsf
Copy link
Member

solracsf commented Mar 9, 2026

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

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.

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

3 participants