thedevdojo / voyager

Voyager - The Missing Laravel Admin
https://voyager.devdojo.com
MIT License
11.78k stars 2.67k forks source link

Unsupported images end with error 500 instead of a validation error #5203

Closed Gicminos closed 3 years ago

Gicminos commented 3 years ago

Version information

Description

I believe this is not a duplicate of https://github.com/the-control-group/voyager/issues/4543 . When a user uploads an SVG or any other image file not supported, submit returns with a 500 error instead of a user-friendly message saying that the image file is not valid.

Steps To Reproduce

Steps to reproduce the behavior:

  1. Create or edit an existing item with a picture field
  2. Upload an image not supported by the GD driver
  3. Submit
  4. See error 500

Expected behavior

A clear and concise description of what you expected to happen. This screenshot is an example suggestion: image

Screenshots

image

emptynick commented 3 years ago

From my point of view a SVG file is not an image. Instead of using the image-type, why don't you simply use a standard file-type? You might have to override some views to display it - but you'd have to do the same with image-type. If that's not sufficient, you can always add a validation rule.

Gicminos commented 3 years ago

Thanks for your message,

Your point makes sense, but I filed this bug not because I need to support the SVG type, but because when the form is accessed by non-tech users they receive this error that I believe not to be user-friendly.

Hence my suggestion was to let voyager handle this error so that it would not be threw to the user.

If this is possible to be prevented via validation rules, accept my apologies in advance as I was not aware of it.

MrCrayon commented 3 years ago

@Gicminos when you create a form with Voyager it's your duty to set validation rules so that the user cannot send anything unexpected and receive proper errors.

You can check Voyager documentation about how to apply validation and Laravel documentation about the rules: https://voyager-docs.devdojo.com/bread/introduction#validation https://laravel.com/docs/master/validation#rule-mimetypes

If I misunderstood your problem we can reopen this issue.

github-actions[bot] commented 3 years ago

This issue has been automatically locked since there has not been any recent activity after it was closed. If you have further questions please ask in our Slack group.