-
Notifications
You must be signed in to change notification settings - Fork 71
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
JQAjax>>#callback:json: and invalid json #1363
Comments
Perhaps like this?
|
Hmmm.. , 'null' is valid json and parses to nil. Perhaps this is better:
|
Hi @adriaon The error should be caught by the Seaside exception handler, which will return an error 500. |
Since the urls for a Though, if one wants to return a bad request (status 400), it should be possible to catch the As such, I don't think we should alter the behavior of the callback. Similar situations can arise in all callbacks that accept values sent from the client. If they are tampered with and an error results, it should be considered normal. Perhaps there are other reasons but as such, I don't think we should alter the callback implementation. |
Hi @jbrichau , Thanks for your replies. Some considerations and thoughts from my end. We see errors 500 as indications of 'bugs' or 'shortcomings' in our server. They are monitored and they are bad for our reputation. JQAjax>>#callback:json: is the only place in Seaside where WAJsonParser is used (in my image), besides REST APIs. JQAjax>>#callback:json: might be the only place where programmers can't do any sanity checks before the input gets processed, even-though it is 'just' parsing. Dealing with WAJsonSyntaxError in the configured exception handler broadens the scope (enormously), which I think is undesirable. To compensate this, the configured error handler needs to be even more complex. Those points made me think JQAjax>>#callback:json: is the best place to deal with it. Cheers, |
Hey @adriaon, Well, in my opinion, when a I can imagine adding a new method with an optional error handler block (e.g. |
Hi @jbrichau, Fair enough. I make my own method. Probably named #callback:untrustedJson:. Because with #callback:json:onInvalidJson: all senders need to supply the same error handling block. Cheers. |
Hey @adriaon I'm not trying to reject adding this possibility to Seaside. I am, however, making the point that we should make this change optional and preserve existing behavior. |
Hi @jbrichau, No worries. Didn't want to come across harsh. We are just pair-programming :-). Preserving existing behaviour is perfectly fine. Adding #callback:json:catchJsonParseError: is also a possibility. But the one with a block is more flexible. I thought #callback:json:onInvalidJson: is ok and then a shorthand method like #callback:untrustedJson: that calls #callback:json:onInvalidJson: with a default block. For me, either solution is fine. |
Pentesters had fun with JQAjax>>#callback:json: while feeding it invalid json. Shouldn't it catch the json parsing error and respond with a bad request response or provide a hook for this or something?
The text was updated successfully, but these errors were encountered: