Should I use error message or warning message for optional field validations?

I have two types of validation pop-ups (toasts). One is used to display error messages in red and another one is for warning messages in yellow.

I have an (optional) image upload field in my form which accepts only one specific image type.

If a user tries to upload a file which is NOT equal to the specified image type, should I then show the warning message or the error message?