-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Issues with retaining default oneof values #329
Comments
I think this is related to a oneof inside of map values. Here is a PR which has a test that fails on decoding a default value inside a map but not on decoding a default value outside of a map. |
Ah sorry, I messed up my test, they actually pass as expected. |
Currently debugging this without success. Is there still an issue? |
Thanks for checking it out. It's still reproducible for me, but only with my setup from the first post when loading the real proto files, no mocks. The specific issue is any falsy values in the |
Still pinpointing. A minimal .proto causing this seems to be: syntax = "proto3";
message Value {
oneof value_type {
// A boolean value.
bool boolean_value = 1;
}
} With that test: var builder = ProtoBuf.loadProtoFile("./test.proto");
var Value = builder.build("Value");
var value1 = new Value({
boolean_value: false
});
test.strictEqual(value1.value_type, "boolean_value");
var value2 = Value.decode(value1.encode());
test.strictEqual(value2.value_type, "boolean_value"); // fails
test.done(); |
|
This is what happens: When When decoding the (empty) message, it will decode with Do you know how this is handled by the official implementation? Does it encode fields inside of oneof declarations even if set to their default values? |
I believe it does encode the values. I'm not totally familiar with the implementation, but I think the relevant portion is here: |
Thanks very much! It works perfectly. Any chance of tagging a release soon? |
4.1.0 is now on npm |
I'm working on implementing support for the protobuf API of Google Cloud Datastore into gcloud-node. I've hit a sticking point, and I'm not sure exactly where to look in the stack to find the problem.
I made a fork to reproduce: https://github.com/stephenplusplus/protobuf.js. I eliminated all of the tests other than mine that fails: https://github.com/stephenplusplus/ProtoBuf.js/blob/master/tests/suite.js
When I mocked the structure of the Google proto files into one test proto file, the tests passed. But when I plug in the real files, it fails.
Sorry to dump a bunch of code on you; if you think this should be asked somewhere else, feel free to close. Thanks for any help!
The text was updated successfully, but these errors were encountered: