Replace buf.Read with io.ReadFull to prevent partial read failures #63
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.



What Changed
Fix critical deserialization bug in go-subtree where
buf.Read()calls could return partial reads, causing "unable to read conflicting node X" errors.Problem
The subtree deserialization code used
buf.Read()in multiple places, checking if the returned byte count matched the expected amount:However, bufio.Reader.Read() is allowed to return fewer bytes than requested even when more data is available. When the internal buffer had only 8 bytes remaining (common at 32KB buffer boundaries), it would return those 8
bytes immediately instead of the requested 32, causing the error check to fail.
This manifested as consistent failures at the same conflicting node index (e.g., 1376) across multiple servers because they all had the same buffer size and file layout.
Solution
Replaced all buf.Read() calls with io.ReadFull(), which guarantees reading the full requested amount or returning an error. Also: