-
Notifications
You must be signed in to change notification settings - Fork 1.6k
jsonpb: improve error reporting #266
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
Comments
@bcmills any thoughts on upstreaming the fixes to jsonpb error reporting in https://github.com/mwitkow/go-nicejsonpb? |
It probably would be a good idea to make error reporting clearer. How would your proposal fit in with #256? |
@bcmills I commented there: Thoughts? |
It's a bit hard to tell what the proposed changes are because the commit history of |
Oh, of course. The field path construction can be moved to the error itself
and avoid allocation. We use nicejsonpb to validate config files so there
was no need for performance considerations.
I'll refactor the change into a proper PR once I'm back from vacation.
…On Fri, 3 Mar 2017, 20:42 Bryan C. Mills, ***@***.***> wrote:
It's a bit hard to tell what the proposed changes are because the commit
history of go-nicejsonpb seems to be truncated, but I see a lot of
fmt.Sprintf calls in the error construction path which seem like they'll
add a lot of unnecessary allocations. Perhaps there's a more efficient way
to structure the errors to give a better balance of overhead and clarity?
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#266 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AJNWo_Ku2ViH7O1p5uqXagve85_wZkBBks5riHsFgaJpZM4LGYkX>
.
|
\cc @cybrcodr |
I'm using a fork with the patch from #310 and it's been really useful. It would be nice to have support upstream :) |
Is there some reason the PR has not been applied? Using jsonpb is extremely difficult in production with external providers as and error in the input stream is nearly impossible to diagnose. This is an example of re-using the error structs from 'json' and then 'zeroing' fields - when this package should probably define it's own error types. |
This logic has been completely re-written in the next major release of Go protobufs. We are only applying bug fixes at this point to the current code base. Better error messages is nice-to-have, but is not a bug fix. |
Why can't you apply the PR as a back fix? Error diagnosis is nearly impossible with the current version. It is a real problem when dealing with external systems that may be generating the json not via protobufs. And the bug is there for 3+ years? |
The JSON implementation for protobuf has been completely rewritten in the v1.20.0 release release that this is unlikely to still be an issue. If the new error output is still insufficient, new issues can be filed. |
JsonPB has very unhelpful error reporting. For example:
json: cannot unmarshal string into Go value of type []json.RawMessage
Its unclear what field this is about (and for multi nested messages it is a huge), and even the type
[]json.RawMessage
is incorrect ([uint32
]). I forked thejsonpb.Unmarshaller
at go-nicejsonpb and introduced few improvements:For a comparison of outputs, here's a test against normal
jsonpb
with the expected values being fromnicejsonpb
I'd happily upstream it, but would like to know whether introducing a new
jsonpb.FieldError
is a viable option for upstream. @bcmills, thoughts?The text was updated successfully, but these errors were encountered: