Skip to content

V16: XHR requests do not report the underlying problem details object #19160

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 7 commits into
base: release/16.0
Choose a base branch
from

Conversation

iOvergaard
Copy link
Contributor

@iOvergaard iOvergaard commented Apr 25, 2025

Description

Two problems are solved here:

XHR Requests and Problem Details

XHR requests created through the UmbTryXhrRequestController did not map back the underlying problem details object, resulting in details being lost, which then resulted in a blank error notification as outlined in #19154. This has been fixed in the controller.

This now means that error notifications are shown again:
image

And this fixes #19154

MaxFileSize is not being detected

If the developer fails to inform us of the intended max file size (also known as the max request length), we have no way of using this to validate the file size before attempting an upload. This results in a 413 error on the server, which is then wrapped into a problem details object.

This Pull Request attempts to recognize these errors (at least when uploading temporary files) by disabling notifications and checking on the error itself in the UmbTemporaryFileManager. It also tries to guess what the max file size could be based on the server error.

So we get the friendly error even when the server failed the request:
image

This fixes #18994

Additionally

I went through the dictionary import and user avatar to ensure that they, too, use the UmbTemporaryFileManager, which will now correctly validate temporary file uploads, handle queueing (although that is negligible for singular file uploads), and support cancelling the file upload network request.

How to test

Test the default settings

All of this can be tested by going to any of the uploads, for example, user avatar, dictionary import, or media library "create" and then uploading a file that is too large. By default, this is 50 MB on Kestrel only if you have not set the MaxRequestLength in appsettings.

Test an applied MaxRequestLength

Add this to your app settings:

{
  "Umbraco": {
    "CMS": {
      "Runtime": {
        "MaxRequestLength": 1
      }
    }
  }
}

Now, try and upload a file larger than 1 KB and it should fail directly on the client before even being attempted to upload.

@iOvergaard iOvergaard added category/ux User experience type/bug area/frontend release/16.0.0 preview/backoffice Pull requests that can be previewed in a static version of the Backoffice labels Apr 25, 2025
@Copilot Copilot AI review requested due to automatic review settings April 25, 2025 16:51
Copy link
Contributor

@Copilot 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 two issues: the loss of underlying problem details in XHR error responses and the improper handling of max file size validations for file uploads.

  • Updated XHR request handling to properly extract and forward problem details.
  • Migrated temporary file functionality from a repository to a manager implementation with enhanced error handling.
  • Extended changes to user avatar and dictionary import components to incorporate the new temporary file manager.

Reviewed Changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
src/Umbraco.Web.UI.Client/src/packages/user/user/workspace/user/components/user-workspace-avatar/user-workspace-avatar.element.ts Added allowed file types and temporary file configuration observation for avatar uploads.
src/Umbraco.Web.UI.Client/src/packages/user/user/repository/avatar/user-avatar.repository.ts Replaced the legacy temporary file repository with the new temporary file manager for avatar uploads.
src/Umbraco.Web.UI.Client/src/packages/dictionary/entity-action/import/import-dictionary-modal.element.ts Updated file upload handling to use the temporary file manager and manage import state.
src/Umbraco.Web.UI.Client/src/packages/core/temporary-file/temporary-file.server.data-source.ts Disabled notifications for temporary file uploads.
src/Umbraco.Web.UI.Client/src/packages/core/temporary-file/temporary-file-manager.class.ts Refactored file size validation and error handling with improved notification of file size limits.
src/Umbraco.Web.UI.Client/src/packages/core/resources/tryXhrRequest.function.ts Updated error rejection to use a centralized error response creator with problem details extraction.
src/Umbraco.Web.UI.Client/src/packages/core/resources/try-execute.controller.ts Improved error handling by extracting problem details through type validation.
src/Umbraco.Web.UI.Client/src/packages/core/resources/api-interceptor.controller.ts Enhanced interception logic to check for valid problem details and use them for error notifications.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/frontend category/ux User experience preview/backoffice Pull requests that can be previewed in a static version of the Backoffice release/16.0.0 type/bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant