When I attempt to upload a file into a required file or image field whose extension isn't in the list of allowed extensions I get the following error:

The specified file views.view_.content.yml could not be uploaded.
Only files with the following extensions are allowed: png gif jpg jpeg.
This value should not be null.

The odd thing is the last part: "This value should not be null."

Screenshot of error message

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

rooby created an issue. See original summary.

ajalan065’s picture

IMHO, this field is a required one, and when we upload a file with the unacceptable extension and submit the form. The validation discards the file uploaded, resulting this field to attain null value, hence this error.
Please correct me if I am wrong.

rooby’s picture

Title: Strange error when uploading an invalid file into an image field » Strange error when uploading an invalid file into a required image field
Issue summary: View changes

I can confirm that if I make the field optional then the last part of the message ("This value should not be null.") is no longer there.

rooby’s picture

Title: Strange error when uploading an invalid file into a required image field » Strange error when uploading an invalid file into a required file/image field
Issue summary: View changes

This also happens for required file fields.

ajalan065’s picture

This shows that the required field has NOT NULL attribute in the database as is in most of the cases.

dhiraj bhagat’s picture

Have you fixed this issue I am getting same issue. I am unable to upload any file.

david.fcondezo’s picture

Did anybody find a solution for this?

pameeela’s picture

Version: 8.1.1 » 10.0.x-dev
FileSize
26.26 KB

I'm unable to reproduce this on 9.0.0. Screenshot attached, "This value should not be null." is no longer appearing.

@rooby, I'm going to close this as cannot reproduce given that it can't be reproduced any longer. I suspect it was fixed as a result of a change somewhere else, probably in #2377747: Incorrect node create validation error when an invalid image is attached to a field.

If anyone else is still able to produce this error, please re-open this ticket with complete steps to reproduce the issue (starting from "Install Drupal core"), document those steps in the issue summary and set the issue status back to "Active".

pameeela’s picture

Status: Active » Closed (cannot reproduce)
Issue tags: +Bug Smash Initiative