-
-
Notifications
You must be signed in to change notification settings - Fork 253
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
Changed exception type for invalid input between 3.3.6 and 3.3.7 #441
Comments
In 3.3.6 I attempted to catch empty string as an error which also catches the string you provided. Unfortunately I used the wrong exception so it was inconsistent with Rails and the JSON gem. 3.3.7 fixes that. Since it was short period of time between the releases I didn't think too many people would notice the change so I did not bump the version to 3.4 as the change in API from one exception type to another didn't feel that significant. |
Update: I see that for compatibility mode and NOT mimicking the JSON gem that the type is EncodingError. I should have read you issue more carefully. It should be Oj::ParseError is not mimicking JSON. |
I had a look at the code we ran into this with, the relevant line where we used to catch the Oj::ParseError was added around two months ago, so it must have been the behavior for versions prior to 3.3.6, too, since that was released later. It's not giving us headaches, we simply catch the EncodingError too, now, but it seemed an API change notable enough to at least give you a heads up on it :) Like I said, I'd prefer Oj to give me an exception owned by the gem itself, so I preferred the old behaviour, but feel free to close this issue if the new behaviour is desired :) |
I'll make the error a Oj::ParseError unless in :compat mode or :rails mode. It will have to wait a few more days before I can get to it though. |
Just pushed a 'parse-error' branch that should use Oj::ParseError instead of EncodingError in all cases other than with the JSON gem or Rails. |
Any comments? |
Is this still of interest or should I let it slide into oblivion? |
Hi Peter, issue has just come to my interest by means of an intricate entanglement: We are using
This causes a rather unintuitive chain of events when updating
So, your change is definitely of public interest because of bad architectural decisions on many sides, and I'm not sure which component should best be adapted (or replaced). |
Thanks for the background. Are you asking for a change in the current Oj version? |
Since the resulting error message references Yet I am not sure what to do about this: Reverting back to the old style of throwing exceptions would cure the symptoms, not the problems. |
Note that |
That is a very old version of Oj. I believe Oj is raising an |
Yes, we do also have |
That does present a problem. Of course Oj can not mimic the JSON gem and then raise incompatible exception types. Good luck with getting the gems updated. |
@ohler55 sorry for the late reply, for us the problem is not relevant anymore, since we just adjusted the rescue to also handle encoding errors. Thanks! |
Hey there,
I noticed a change of behaviour between versions 3.3.6 and 3.3.7: When passing entirely wrong input, before Oj used to raise
Oj::ParseError
incompat
mode. With 3.3.7, it givesEncodingError
:Output for the two versions:
Not sure if this is intentional, but this feels like a breaking change to me. It's also awkward that now the exception is a standard-ruby one as opposed to the previous Oj-specific exception, so my guess would be this change was unintentional?
The text was updated successfully, but these errors were encountered: