-
Notifications
You must be signed in to change notification settings - Fork 5
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
Unable to read from bepop from file content #46
Comments
|
I have debugged bepop lib a bit more and noticed that what actually happens is that ErrorReader is not wrapped again in case it is already ErrorReader (case for nested messages).
So basically the following lines corrupts ErrorReader from parent DecodeBebop call.
I fixed the autogenerated code by unwrapping the ErrorReader in case it is already ErrorReader:
or another possible solution is:
|
I can run the test and reproduce the failure. But, we do not want nested messages to allocate their own error reader. I'll look into it. |
@matejsp This is working as intended right now; the EOF is accurate, the file reached its end. Many libraries that work with readers return EOF in success cases; in Bebop's case we return io.ErrUnexpectedEOF if there's a problem. I'm open to discarding EOF errors from Decode methods if the method is at a valid endpoint, if you want to write that PR. |
@200sc
If you don't want to nested message to have its own ErrorReader ... Perhaps alternative solution would be to return Reader instance back to its original value using defer:
or after draining the outer limited reader:
|
@matejsp Please review the linked PR with a patch. |
@200sc I have tested and yes by reseting limitReader on each for loop before reading ReadByte) is preserving the limited reader and it works in our case so this resolves this bug. |
Merged, v0.6.1 including this patch is released. Thank you for the report! |
@200sc It is still not ok for one case when you read in a for loop:
Code:
|
@200sc Can you reopen the issue please. |
@200sc = |
Given the following schema and using: github.com/200sc/bebop v0.6.0:
And code to write and read from schema:
I get:
Now the file content is as follows:
The text was updated successfully, but these errors were encountered: