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...

Comments

jhodgdon’s picture

Version: 7.x-dev » 8.x-dev
Component: documentation » file.module

Sounds like a code, not documentation issue report.

jyee’s picture

StatusFileSize
new1.6 KB

How about, "An unrecoverable error occurred. The submitted information does not match the generated form. Try reloading the page and submitting again."?

That should provide a hint for developers that there's a mismatch between the submission and generation (i.e. form build id submitted does not match the actual form). It's also not overwhelming or scary for end users. Assuming that there's nothing intentionally resetting the build id, reloading the page would correct the build id and be an appropriate next-step for end users.

matthieu.symetris’s picture

I think it's great,
will it be implemented in the next release of drupal 7.x and 8.x? I'm not familiar with the proccess of suggesting code ajustement to drupal. Should I change the status of this super-minor issue? :)

Thank you very much jyee.

jyee’s picture

Status: Active » Needs review

@matthieu.symetris: The general process is for this to be reviewed and for other Community members to comment on it. Then, assuming there's consensus to accept this solution, a Drupal project maintainer can commit it.

Status: Needs review » Needs work

The last submitted patch, misleading_error_message-1452128-2.patch, failed testing.

jyee’s picture

Status: Needs work » Needs review
StatusFileSize
new901 bytes

So, I'm not sure why that first patch had a couple unrelated code changes. Here's a clean patch against D8 (hash: 467a825239bdd34a84e18064cb6c8ac8ecb7bb1f). I also generated it from Drupal root.

adamdicarlo’s picture

The patch looks good to me. Though it passing does reveal that there is no test for this failure case, right? Does this need a test case?

jyee’s picture

Do you mean a test to corrupt the form build id in order to verify that this error message appears as expected?

liam morland’s picture

The original error message is a correct, at least in some circumstances. I am seeing this error when trying to upload files that are larger than the maximum configured in PHP.

alansaviolobo’s picture

Issue summary: View changes

is it not possible to catch the large file error separately ?

jhedstrom’s picture

Version: 8.0.x-dev » 8.1.x-dev
Status: Needs review » Needs work
Issue tags: +Needs reroll

Patch no longer applies. Needs to be bumped to 8.1 since beta freezes strings.

liam morland’s picture

Status: Needs work » Needs review
StatusFileSize
new1.06 KB

Reroll.

jhedstrom’s picture

Version: 8.1.x-dev » 8.0.x-dev
Issue tags: -Needs reroll

I was incorrect in #11. Beta did not freeze strings. Back to 8.0.

Status: Needs review » Needs work

The last submitted patch, 12: core-1452128-misleading_error_message-12.patch, failed testing.

Status: Needs work » Needs review
liam morland’s picture

Version: 8.0.x-dev » 8.1.x-dev
StatusFileSize
new1.21 KB

Reroll.

Version: 8.1.x-dev » 8.2.x-dev

Drupal 8.1.0-beta1 was released on March 2, 2016, which means new developments and disruptive changes should now be targeted against the 8.2.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.2.x-dev » 8.3.x-dev

Drupal 8.2.0-beta1 was released on August 3, 2016, which means new developments and disruptive changes should now be targeted against the 8.3.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.3.x-dev » 8.4.x-dev

Drupal 8.3.0-alpha1 will be released the week of January 30, 2017, which means new developments and disruptive changes should now be targeted against the 8.4.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.4.x-dev » 8.5.x-dev

Drupal 8.4.0-alpha1 will be released the week of July 31, 2017, which means new developments and disruptive changes should now be targeted against the 8.5.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.5.x-dev » 8.6.x-dev

Drupal 8.5.0-alpha1 will be released the week of January 17, 2018, which means new developments and disruptive changes should now be targeted against the 8.6.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.6.x-dev » 8.7.x-dev

Drupal 8.6.0-alpha1 will be released the week of July 16, 2018, which means new developments and disruptive changes should now be targeted against the 8.7.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.7.x-dev » 8.8.x-dev

Drupal 8.7.0-alpha1 will be released the week of March 11, 2019, which means new developments and disruptive changes should now be targeted against the 8.8.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.8.x-dev » 8.9.x-dev

Drupal 8.8.0-alpha1 will be released the week of October 14th, 2019, which means new developments and disruptive changes should now be targeted against the 8.9.x-dev branch. (Any changes to 8.9.x will also be committed to 9.0.x in preparation for Drupal 9’s release, but some changes like significant feature additions will be deferred to 9.1.x.). For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Version: 8.9.x-dev » 9.1.x-dev

Drupal 8.9.0-beta1 was released on March 20, 2020. 8.9.x is the final, long-term support (LTS) minor release of Drupal 8, which means new developments and disruptive changes should now be targeted against the 9.1.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Version: 9.1.x-dev » 9.2.x-dev

Drupal 9.1.0-alpha1 will be released the week of October 19, 2020, which means new developments and disruptive changes should now be targeted for the 9.2.x-dev branch. For more information see the Drupal 9 minor version schedule and the Allowed changes during the Drupal 9 release cycle.

mitthukumawat’s picture

The patch applied cleanly on the Drupal 8.1.x-dev version but not in Drupal 9.2.x-dev version. So adding patch for 9.2.x-dev version.

Status: Needs review » Needs work

The last submitted patch, 27: core-1452128-misleading_error_message-17.patch, failed testing. View results

Version: 9.2.x-dev » 9.3.x-dev

Drupal 9.2.0-alpha1 will be released the week of May 3, 2021, which means new developments and disruptive changes should now be targeted for the 9.3.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

nikitagupta’s picture

Status: Needs work » Needs review
StatusFileSize
new2.41 KB
new998 bytes

Version: 9.3.x-dev » 9.4.x-dev

Drupal 9.3.0-rc1 was released on November 26, 2021, which means new developments and disruptive changes should now be targeted for the 9.4.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.4.x-dev » 9.5.x-dev

Drupal 9.4.0-alpha1 was released on May 6, 2022, which means new developments and disruptive changes should now be targeted for the 9.5.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.5.x-dev » 10.1.x-dev

Drupal 9.5.0-beta2 and Drupal 10.0.0-beta2 were released on September 29, 2022, which means new developments and disruptive changes should now be targeted for the 10.1.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

smustgrave’s picture

Status: Needs review » Needs work
Issue tags: +Needs Review Queue Initiative, +Needs issue summary update

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.

lucassc’s picture

Status: Needs work » Needs review
StatusFileSize
new2.43 KB

Rerolled for 10.1.x

smustgrave’s picture

Status: Needs review » Needs work

Thank you for working on this.

When uploading patches please include an interdiff file also

Moving back to NW for the issue summary update.

lucassc’s picture

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.

smustgrave’s picture

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

liam morland’s picture

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

lucassc’s picture

Status: Needs work » Needs review
StatusFileSize
new2.38 KB
new2.25 KB

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: Needs review » Needs work

The last submitted patch, 40: 1452128-40.patch, failed testing. View results

pameeela’s picture

Title: Misleading error message » Misleading error message when uploading a file

Version: 10.1.x-dev » 11.x-dev

Drupal core is moving towards using a “main” branch. As an interim step, a new 11.x branch has been opened, as Drupal.org infrastructure cannot currently fully support a branch named main. New developments and disruptive changes should now be targeted for the 11.x branch, which currently accepts only minor-version allowed changes. For more information, see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 11.x-dev » main

Drupal core is now using the main branch as the primary development branch. New developments and disruptive changes should now be targeted to the main branch.

Read more in the announcement.