-
Notifications
You must be signed in to change notification settings - Fork 411
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
Can we provide better error messages for jsoniter? #3803
Comments
This may be tricky, see here: plokhotnyuk/jsoniter-scala#992
We could catch jsoniter's
|
Most JSON parsers (e.g. circe, zio-json, smithy4s-json) do tracking of the current JSON path during parsing, but it burns a lot of CPU cycles and reduce memory bandwidth. From the beginning jsoniter-scala was designed to parse UTF-8 input from byte arrays and buffers (not strings) on servers for matured ad-tech protocols like OpenRTB where most of fields are optional or have meaningful default values. Pointing with an exact byte location and a textual dump helped a lot to fix JSON/UTF-8 encoding errors (like malformed bytes or wrong escaping sequences) on the client side. For some services that works with personal data having those errors logged could be insecure, so in a runtime configuration for parser users can switch off dumping while keeping hex offset printed in the error message. Also, for debugging purposes the size of hex dumps could be increased using this option. I vote to preserve hex offset, because it helps to point on problematic places without relaying on uniqueness of field names or developer intuition. Also, please consider an ability for user to pass the |
Keeping the offset indeed sounds safe and may be helpful. We could use
Right now, Tapir uses just the default |
Currently when a JSON body fails to decode, when using jsoniter, a generic error is returned. Can we somehow extract information from jsoniter, when parsing fails, which would point to the path of the failure? Something like that is already available e.g. for circe.
The text was updated successfully, but these errors were encountered: