-
Notifications
You must be signed in to change notification settings - Fork 533
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
More information from DecodeError #158
Comments
Off the bat: I don't have a philosophical objection to exposing more error details if they are reliably available, but I believe this particular case isn't cut and dry. It's not possible, in general, to distinguish between a malformed input and buffer underrun (just so we're on the same page, I'm taking that to mean the caller failed to pass in the full message worth of bytes). For example, when decoding a string field in a message. The length tag says the string field should be 100 bytes, but there is fewer than that remaining. Is that a buffer under-run, or a malformed length tag? The situation is perhaps a bit more approachable if you limit yourself to only trying to distinguish between malformed input and buffer under-run in the case of decoding a top-level length-delimited message. In principal |
I probably don't have enough internal knowledge about how exactly protobufs work. I'd probably still think that case is a buffer under-run, which is a special case of malformed message. But for example a wrong type of a field (eg trying to put an integer into a string) would be another case of malformed message. For the underrun case, adding more bytes could but wouldn't have to „solve“ the error, while for the latter one, it surely wouldn't. Anyway, I was actually reading the documentation of the |
Hello
I know you mentioned in #106 that you don't want to change the DecodeError. However, being able to get some information from the error might be useful to handle it differently ‒ yes, one of the possibilities is buffer underrun.
So I would be interested to know what your rationale for not wanting the change the error type is. I guess it's one of these:
decode_length_delimiter
(maybe this should be mentioned in its docs)?If it's just the second, would it be OK to still hide the details, but add some methods to it, like
is_buffer_underrun
? This seems to be the case other libraries take when they want to provide more info.The text was updated successfully, but these errors were encountered: