Skip to content

FIX Report create-folder errors instead of failing silently - #1691

Open
edwilde wants to merge 1 commit into
silverstripe:3.2from
edwilde:pulls/3.2/surface-create-folder-errors
Open

FIX Report create-folder errors instead of failing silently#1691
edwilde wants to merge 1 commit into
silverstripe:3.2from
edwilde:pulls/3.2/surface-create-folder-errors

Conversation

@edwilde

@edwilde edwilde commented Jul 19, 2026

Copy link
Copy Markdown

Description

Creating a folder could fail silently. The Create button showed its loading state, then reverted to "Create" with no error. This happens when the current user cannot create in the target folder, for example a protected parent whose children inherit permissions after a CMS 5 to 6 upgrade.

AssetAdmin::createfolder() threw an InvalidArgumentException for both the "parent not found" and "permission denied" cases. The client had no structured error to display, so the failure was swallowed.

Change

  • Return structured HTTP responses from createfolder():
    • 404 with FOLDER_NOT_FOUND ("Folder not found") when the parent folder cannot be found.
    • 403 with CreateFolderPermissionDenied ("You do not have permission to create a folder") when Folder::canCreate() denies.
  • Surface the returned message as a toast in the asset admin.
  • Add the two i18n strings, following the existing CreatePermissionDenied pattern.

This makes the "no error message" behaviour visible to the user. It does not change why permission is denied. The underlying permission-inheritance cause is being addressed separately.

Related

Addresses the missing-error-message aspect of #1689. The underlying permission-inheritance denial is tracked separately, so this does not close the issue.

Tests

  • PHP: AssetAdminTest covers the 403 and 404 responses.
  • JS: AssetAdmin-test.js covers the error toast.

AssetAdmin::createfolder() threw an InvalidArgumentException when the parent folder was missing or the permission check denied creation. The client could not interpret that, so the Create button reverted to its label with no message.

Return structured HTTP errors instead: 404 "Folder not found" when the parent is gone, and 403 "You do not have permission to create a folder" when Folder::canCreate() denies, and surface the returned message as a toast.
@edwilde
edwilde marked this pull request as ready for review July 20, 2026 21:17
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.

1 participant