Skip to content

Conversation

@AndyButland
Copy link
Contributor

Prerequisites

  • I have added steps to test this contribution in the description below

Fixes: #20620

Description

Seems with legacy data the configuration for fileExtensions under an upload field data type can be null, which we aren't expecting in backend code. So this PR just defensively ensures we are working with an empty collection and never null.

Testing

There's a method using uSync described in the linked issue, but I replicated the problem and verified the fix with the following:

  • Modified the stored configuration for the Upload (Audio) data type with:
update umbracoDataType
set config = '{"fileExtensions": null}'
where nodeId = -101
  • Restarted to clear caches

  • Made a call to the following: /umbraco/management/api/v1/item/media-type/allowed?fileExtension=mp3&skip=0&take=100

    • Before this update the exception reported in the linked issue should be shown
    • After you should get back a collection of data types
  • Reset my database with:

update umbracoDataType
set config = '{"fileExtensions":["mp3","weba","oga","opus"]}'
where nodeId = -101

Release

On approval and merge this will go into 16.4. Let me know if you are happy this goes into 17.0 which I would say is OK given we are in the beta period still. Otherwise it'll be 17.0.

Copilot AI review requested due to automatic review settings October 24, 2025 06:20
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR addresses a null reference exception that occurs when legacy data contains null file extensions in the upload field data type configuration. The fix defensively handles null values by ensuring an empty collection is used instead, preventing the application from crashing when querying allowed media types by file extension.

Key Changes:

  • Added null-coalescing operator to handle null FileExtensions configuration values in media type editing service

Copy link
Contributor

@nikolajlauridsen nikolajlauridsen left a comment

Choose a reason for hiding this comment

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

Looks good to me 👍

Given the type of fix this is, I think it's fine to go into 17.0, I'll cherry-pick it 😄

@nikolajlauridsen nikolajlauridsen merged commit f33eb3f into main Oct 27, 2025
25 checks passed
@nikolajlauridsen nikolajlauridsen deleted the v16/bugfix/handle-null-file-extensions-when-populating-allowed-media-types branch October 27, 2025 12:42
nikolajlauridsen pushed a commit that referenced this pull request Oct 27, 2025
…llowed media types (closes #20620) (#20635)

* Handle null configured file extensions when populating allowed media types.

* Added clarifying comment.

(cherry picked from commit f33eb3f)
@nikolajlauridsen
Copy link
Contributor

Cherry picked for 17.0 🍒

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.

Unable to drag and drop a file into media section - 500 error for allowed file extension check

3 participants