fix: empty buffers submitted to a repeated bytes field were converted to undefined#1500
Closed
jawid-h wants to merge 2 commits intoprotobufjs:masterfrom
Closed
fix: empty buffers submitted to a repeated bytes field were converted to undefined#1500jawid-h wants to merge 2 commits intoprotobufjs:masterfrom
repeated bytes field were converted to undefined#1500jawid-h wants to merge 2 commits intoprotobufjs:masterfrom
Conversation
reapeated bytes field were converted to undefinedrepeated bytes field were converted to undefined
Contributor
|
@jawid-h The change looks good to us, could you add a test that would cover this situation? Thank you! |
Contributor
|
I would like to move this issue forward as it is causing some problems with the google datastore node client (googleapis/nodejs-datastore#755). This is the test case I have tried to add to this PR: test.test(test.name + " - Message.toObject with empty buffers", function(test) {
var msg = Message.create({
bytesVal: protobuf.util.newBuffer(0),
});
test.equal(Message.toObject(msg, { bytes: String }).bytesVal, "", "bytes to base64 strings");
if (protobuf.util.isNode) {
const bytesVal = Message.toObject(msg, { bytes: Buffer }).bytesVal;
test.ok(Buffer.isBuffer(bytesVal), "bytes to buffers");
test.equal(bytesVal.length, 0, "empty buffer");
}
test.end();
}); However it seems to be causing unrelated troubles. Would you have any hints on the best way to test this PR ? Thanks |
Contributor
|
Taken care of by #1514. |
bcoe
pushed a commit
that referenced
this pull request
Dec 7, 2020
closes #1500 fixes #885 Co-authored-by: Benjamin E. Coe <[email protected]>
This was referenced Jul 8, 2022
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
I believe it is related to the following issue (#885). We're experiencing the same problem.
When we're having following
messagein.protofile:and trying to submit an empty
Bufferinobjectslist field, the code compiled byprotobufjsignores it. I believe by having following statement:This PR fixes that by including zero-length buffers in the check.