Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Proper input validation on non-string fields #1164

Closed
CryoByte33 opened this issue Dec 28, 2021 · 7 comments
Closed

Proper input validation on non-string fields #1164

CryoByte33 opened this issue Dec 28, 2021 · 7 comments
Labels
bug Something isn't working enhancement New feature or request

Comments

@CryoByte33
Copy link

CryoByte33 commented Dec 28, 2021

Is your feature request related to a problem? Please describe.
Yes, my wife and I just wasted 2 hours trying to figure out why our recipe was giving us a 400 when saving it. It turns out that there's not really any input validation on the "Servings" field, us using "6 to 12" caused 400s that showed almost nothing, even in debug mode.

Describe the solution you'd like
A box that gives a reason why saving the recipe is failing, at least if the answer is something as simple as input errors.

Describe alternatives you've considered
A simpler solution may be a tooltip that specifies the types of data permitted in any given field. "Servings" would specify that it must be an integer, for example.

Additional context
The error logs with debug mode on are painfully sparse, this is the entirety of what I had to work with, sanitizing my server URL:

recipe-web            | 172.19.0.18 - - [28/Dec/2021:05:21:46 +0100] "PUT /api/recipe/2/ HTTP/1.0" 400 45 "https://recipes.example.com/edit/recipe/internal/2/" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:95.0) Gecko/20100101 Firefox/95.0"

Edit: I just wanted to say that we love the software, I realized after submitting that this sounded very harsh and that wasn't the intent!

@CryoByte33 CryoByte33 added the enhancement New feature or request label Dec 28, 2021
@vabene1111
Copy link
Collaborator

i am so sorry 🙈 i had the same problem recently when leaving the field empty and thought i added proper validation. In general the whole frontend error collection system needs to be improved with a quick and easy way to open a GH issue to report stuff like this. filing this as a bug to get it high up on my todo.

@vabene1111 vabene1111 added the bug Something isn't working label Dec 28, 2021
@CryoByte33
Copy link
Author

Thank you! We really love Tandoor and have been porting our numerous cookbooks into it, but one of the cookbooks uses "x to y" serving sizes instead of a static number so it threw us for a loop. We both appreciate all the work you're doing!

@quamok
Copy link

quamok commented Dec 30, 2021

same here, i tried to add "250 mL" to servings and I was wondering what was causing the issue! Good thing it's already on the radar.

If I can somewhat hijack the thread, there's also a generic error returned to the user when the ingredient note is too long. Input validation on this field would also be beneficial.

@vabene1111
Copy link
Collaborator

yes the frontend errors need some revisiting. We had to many systems for that in the past but now all pages are migrated to the same API system and same frontend system so i can write a generic error handling system that displays a more useful message or at least some logs that i can use to analyze the problem

@vabene1111
Copy link
Collaborator

ok so added input validation to the fields to only allow numbers and notes to limit to 256 characters, also added some script to verify if entered value is a number so even if something goes wrong this should not happen again.
we need to properly look into how frontend input validation is done best with vue.

@quamok
Copy link

quamok commented Jan 14, 2022

sorry to bump this up, but on v1.0.4 in the "Servings" field, it's still possible to input dots (.) and still getting the "There was an error updating a resource!" error. I wanted to add the 1.5 value but got the error.

Maybe add some input validation regarding dots also?

@TWART016
Copy link

For the decimal in servings there is still an issue @1282

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

4 participants