Skip to content
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

Fixed JS parsing of default map values #6394

Merged
merged 1 commit into from
Jul 24, 2019
Merged

Conversation

chemhack
Copy link
Contributor

We recently recently detected JS protobuf library fail to deserialize any map<uint64,double> data where value is 0.

There has been many cases being reported:

#3351
grpc/grpc-web#533
#4500

In binary format, default map values are not sent, however this is not probably handled in JS library.

This fix is inspired by:

#4687

@googlebot
Copy link

Thanks for your pull request. It looks like this may be your first contribution to a Google open source project (if not, look below for help). Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

📝 Please visit https://cla.developers.google.com/ to sign.

Once you've signed (or fixed any issues), please reply here (e.g. I signed it!) and we'll verify it.


What to do if you already signed the CLA

Individual signers
Corporate signers

ℹ️ Googlers: Go here for more info.

@chemhack
Copy link
Contributor Author

I signed it!

@googlebot
Copy link

We found a Contributor License Agreement for you (the sender of this pull request), but were unable to find agreements for all the commit author(s) or Co-authors. If you authored these, maybe you used a different email address in the git commits than was used to sign the CLA (login here to double check)? If these were authored by someone else, then they will need to sign a CLA as well, and confirm that they're okay with these being contributed to Google.
In order to pass this check, please resolve this problem and have the pull request author add another comment and the bot will run again. If the bot doesn't comment, it means it doesn't think anything has changed.

ℹ️ Googlers: Go here for more info.

@googlebot
Copy link

All (the pull request submitter and all commit authors) CLAs are signed, but one or more commits were authored or co-authored by someone other than the pull request submitter.

We need to confirm that all authors are ok with their commits being contributed to this project. Please have them confirm that by leaving a comment that contains only "I consent." in this pull request.

Note to project maintainer: There may be cases where the author cannot leave a comment, or the comment is not properly detected as consent. In those cases, you can manually confirm consent of the commit author(s), and set the cla label to yes (if enabled on your project).

ℹ️ Googlers: Go here for more info.

@klaemo
Copy link

klaemo commented Jul 17, 2019

I signed it!

@klaemo
Copy link

klaemo commented Jul 17, 2019

I consent.

@chemhack
Copy link
Contributor Author

@TeBoring the CLA bot doesn't seem to work reliably, could you please check this manually? thank you

@TeBoring
Copy link
Contributor

Is it possible to resend a PR with only one person to commit?

@TeBoring TeBoring self-requested a review July 17, 2019 16:49
@TeBoring TeBoring self-assigned this Jul 17, 2019
@googlebot
Copy link

CLAs look good, thanks!

ℹ️ Googlers: Go here for more info.

@chemhack
Copy link
Contributor Author

@TeBoring changed the commit

@RXminuS
Copy link

RXminuS commented Jul 23, 2019

Any indication when this could be merged, it's been a bug with far-reaching consequences in the community (grpc and a few other projects as well). And thank you @chemhack for creating a fix!

@TeBoring
Copy link
Contributor

Could you also add some test into maps_test.js?

@chemhack
Copy link
Contributor Author

@TeBoring it's actually already covered by the JS unit test, but the unit test doesn't catch the bug since the binary message is serialized by JS library as well, which is behaving differently than other language libs.

IMHO the test should belong to conformance test rather in maps_test.js. But i only have very limited knowledge of the codebase and won't have time to dig into the test setup. Hope you can understand that.

@TeBoring
Copy link
Contributor

Ah, I see. Thank you for the fix.

@TeBoring TeBoring merged commit dcc8ffd into protocolbuffers:master Jul 24, 2019
@TeBoring
Copy link
Contributor

When the value of map is message, null is used as the fault, which could cause the problem. Could you add a test and fix the problem?

TeBoring added a commit that referenced this pull request Jul 28, 2019
@chemhack
Copy link
Contributor Author

When the value of map is message, null is used as the fault, which could cause the problem. Could you add a test and fix the problem?

What exact problem were you experiencing? If a value is a message, and not specified, null is the correct default. Are you expecting it to be an empty message instead?

Also, when the key of map is a message, that's exactly the same behavior.

@TeBoring
Copy link
Contributor

When value is message, jspb.BinaryReader.prototype.readMessage complains it cannot accept null.
Also, message cannot be key.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants