Skip to content

Media Picker: Fix media picker folder navigation with "ignore user start nodes" enabled (closes #21840 for 13)#21899

Merged
Migaroez merged 1 commit intov13/devfrom
v13/bugfix/21840-media-picker-with-ignore-start-nodes
Mar 6, 2026
Merged

Media Picker: Fix media picker folder navigation with "ignore user start nodes" enabled (closes #21840 for 13)#21899
Migaroez merged 1 commit intov13/devfrom
v13/bugfix/21840-media-picker-with-ignore-start-nodes

Conversation

@AndyButland
Copy link
Contributor

@AndyButland AndyButland commented Feb 25, 2026

Description

#21840 reports an an issue where the media picker (egacy) threw a TypeError: Cannot read properties of undefined (reading 'path') when navigating into folders, when the data type had "Ignore user start nodes" enabled and the user had restricted media start node permissions.

The bug was a query parameter name mismatch in EntityController.GetResultForAncestors: it read "dataTypeId" from the query string but the client sends "dataTypeKey", so the server never detected the ignoreUserStartNodes configuration.

I've also added a defensive guard in the client-side gotoFolder to handle an empty ancestor path without throwing,

Root cause

This was reported as a regression in recent versions (which is why I looked at it) but the parameter name mismatch in EntityController.cs has existed for years — the GetResultForAncestors method reads "dataTypeId" from the FormCollection, while every other endpoint in the same controller (GetChildren, GetPagedChildren, Search) correctly uses dataTypeKey as a named action parameter. The client has always sent dataTypeKey. This meant ignoreUserStartNodes was effectively always false for the GetAncestors endpoint.

Why it only recently surfaced

The bug was latent until PR #20202 (released in 13.12.0) refactored gotoFolder to properly chain its promises. Before that PR, getChildren(folder.id) was called immediately and unconditionally and not chained to the ancestor resolution promise. So even when $scope.path[0].path threw inside the .then() callback, the error was silently swallowed and the folder's children still loaded. After #20202 correctly chained getChildren after the ancestor path resolution, the exception now rejects the promise chain and prevents the folder contents from loading.

Testing

For manual testing see "Steps to reproduce" on the linked issue.

Copilot AI review requested due to automatic review settings February 25, 2026 06:08
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 fixes a media picker folder navigation bug that caused a TypeError when users with restricted media start node permissions navigated folders while "Ignore user start nodes" was enabled on the data type.

Changes:

  • Fixed parameter name mismatch in EntityController.GetResultForAncestors from dataTypeId to dataTypeKey to match what the client sends and align with other controller methods
  • Added defensive null check in JavaScript gotoFolder to prevent accessing $scope.path[0] when the filtered ancestor array is empty

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
src/Umbraco.Web.BackOffice/Controllers/EntityController.cs Changed query string parameter name from "dataTypeId" to "dataTypeKey" in GetResultForAncestors method to match client request and align with other endpoints in the same controller
src/Umbraco.Web.UI.Client/src/views/common/infiniteeditors/mediapicker/mediapicker.controller.js Added defensive check to prevent TypeError when $scope.path is empty after filtering ancestors

@AndyButland AndyButland changed the title Fix media picker folder navigation with "ignore user start nodes" enabled Media Picker: Fix media picker folder navigation with "ignore user start nodes" enabled (closes #21840 for 13) Feb 25, 2026
Copy link
Contributor

@Migaroez Migaroez 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 and tests out as described

@Migaroez Migaroez merged commit 8230efd into v13/dev Mar 6, 2026
25 checks passed
@Migaroez Migaroez deleted the v13/bugfix/21840-media-picker-with-ignore-start-nodes branch March 6, 2026 10:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants