Misleading error message when uploading a file

Created on 23 February 2012, almost 13 years ago
Updated 24 January 2023, almost 2 years ago

API page: http://api.drupal.org/api/drupal/modules%21file%21file.module/function/f...

Enter a descriptive title (above) relating to file_ajax_upload, then describe the problem you have found:

In the following validation:

if (empty($_POST['form_build_id']) || $form_build_id != $_POST['form_build_id']) {
    // Invalid request.
    drupal_set_message(t('An unrecoverable error occurred. The uploaded file likely exceeded the maximum file size (@size) that this server supports.', array('@size' => format_size(file_upload_max_size()))), 'error');
    $commands = array();
    $commands[] = ajax_command_replace(NULL, theme('status_messages'));
    return array('#type' => 'ajax', '#commands' => $commands);
  }

The error message has absolutly nothing related to the actual error, this greatly mislead a member of our team while debugging one of our feature. I understand the "security implications" of giving an explanation of whats going on to the user but maybe the error message could be something like "An error occured while authorizing the upload of your file." Or something more vague...

Feature request
Status

Needs work

Version

10.1

Component
File module 

Last updated 1 day ago

Live updates comments and jobs are added and updated live.
  • Needs issue summary update

    Issue summaries save everyone time if they are kept up-to-date. See Update issue summary task instructions.

Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • 🇺🇸United States smustgrave

    This issue is being reviewed by the kind folks in Slack, #needs-review-queue-initiative. We are working to keep the size of Needs Review queue [2700+ issues] to around 400 (1 month or less), following Review a patch or merge request as a guide.

    At this time we will need a D10 version of the patch.

    Tagging for IS update for proposed solution and remaining tasks.

  • Status changed to Needs review almost 2 years ago
  • 🇧🇷Brazil lucassc Rio de Janeiro

    Rerolled for 10.1.x

  • Status changed to Needs work almost 2 years ago
  • 🇺🇸United States smustgrave

    Thank you for working on this.

    When uploading patches please include an interdiff file also

    Moving back to NW for the issue summary update.

  • 🇧🇷Brazil lucassc Rio de Janeiro

    My bad, I couldn't attach an interdiff duo to the error below:

    1 out of 1 hunk FAILED -- saving rejects to file /tmp/interdiff-1.BEe0qz.rej
    interdiff: Error applying patch1 to reconstructed file

    But the only difference was that I kept the new D10 statusMessageContainsAfterWait(message, 'error') over the patch's pageTextContains.

  • 🇺🇸United States smustgrave

    No worries!

    I occasionally get that myself. For those what I do is diff old.patch new.patch > diff-[old-patch-number]-[new-patch-number].txt

  • 🇨🇦Canada Liam Morland Ontario, CA 🇨🇦

    In the first hunk, the @size token is removed from the text, so it should not be set in the arguments.

  • Status changed to Needs review almost 2 years ago
  • 🇧🇷Brazil lucassc Rio de Janeiro

    That's right! @size's arguments removed. I took the opportunity to add a final point that was missing.

    And what about these comments?

    // Render a nice error message in case we have a file upload which exceeds
    // the configured upload limit.

    Should we change them too?

    // An error message should appear informing the user that the file exceeded
    // the maximum file size. The error message includes the actual file size
    // limit which depends on the current environment, so we check for a part
    // of the message.
  • Status changed to Needs work almost 2 years ago
Production build 0.71.5 2024