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

[7392] fix conformance test in PHP JSON parser #16743

Conversation

antongrbin
Copy link
Contributor

@antongrbin antongrbin commented May 4, 2024

Motivation

This PR fixes failing JSON conformance tests for php with name IgnoreUnknownEnumStringValue*.

The JSON parsing spec was discussed in #7392.

Recent similar changes in other languages:

@antongrbin antongrbin force-pushed the anton--7392--fix-unknown-enum-php branch 2 times, most recently from 0498647 to 77bb25f Compare June 13, 2024 17:49
@antongrbin antongrbin marked this pull request as ready for review June 13, 2024 17:51
@antongrbin antongrbin requested a review from a team as a code owner June 13, 2024 17:51
@antongrbin antongrbin force-pushed the anton--7392--fix-unknown-enum-php branch from 77bb25f to 367aa3d Compare June 13, 2024 17:51
@antongrbin antongrbin requested review from a team as code owners June 13, 2024 17:51
@antongrbin
Copy link
Contributor Author

@jskeet, since you worked with me on the linked issue #7392, is it OK to ask you to help me find a PHP reviewer to move this forward?

@bshaffer
Copy link
Contributor

@antongrbin I can take a look

@antongrbin
Copy link
Contributor Author

@bshaffer thank you for the review offer && polite ping :)

@antongrbin
Copy link
Contributor Author

@bshaffer friendly ping :)

@JasonLunn JasonLunn added the php label Oct 11, 2024
@JasonLunn JasonLunn requested a review from bshaffer October 11, 2024 19:11
@JasonLunn JasonLunn added the 🅰️ safe for tests Mark a commit as safe to run presubmits over label Oct 11, 2024
@github-actions github-actions bot removed the 🅰️ safe for tests Mark a commit as safe to run presubmits over label Oct 11, 2024
Copy link
Contributor

@bshaffer bshaffer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is really the behavior we want? If an array/map is unknown, it throws an exception unless other valid values exist, at which point the unknown value is ignored?

That does not seem like intuitive behavior to me... what is the justification for this?

EDIT: On second look, I see that the difference between the tests which throw an exception and the tests which do not throw an exception is the true parameter being passed to mergeFromJsonString. This was not obvious, since these tests ALSO differ in that in one, the UNKNOWN field is alone, and in the others, there are two other values in the map/repeated fields.

Comment on lines +245 to +249
"{\"repeated_enum\":[
\"ONE\",
\"UNKNOWN_ENUM\",
\"ZERO\"
]}",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are we using values of ONE and ZERO in some tests, and using ONLY the UNKNOWN_ENUM in others? Let's keep this consistent, or test using both if that's what's desired. Otherwise, changing the JSON string input betwen tests is confusing (as what we are actually testing is the second parameter being true).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great catch! I now made the JSON string inputs equal in each test pair.

@antongrbin
Copy link
Contributor Author

@bshaffer thank you for your time for reviewing this and sorry for the delay.

I recently switched companies so I lost access to noom/protobuf and can't update this PR anymore.

I created a new equivalent PR here: #19376.

@antongrbin antongrbin closed this Nov 23, 2024
copybara-service bot pushed a commit that referenced this pull request Nov 25, 2024
# Motivation

This PR fixes failing JSON conformance tests for php with name `IgnoreUnknownEnumStringValue*`.

The JSON parsing spec was discussed in #7392.

Recent similar changes in other languages:
- Python: 86abf35
- Swift: apple/swift-protobuf#1345
- C#: #15758
- C++: #16479

Note: this PR is equivalent to #16743. I had to create a new one since I lost access to noom/protobuf in the meantime (switched companies recently).

Closes #19376

COPYBARA_INTEGRATE_REVIEW=#19376 from antongrbin:anton--7392--php-newbranch 641a28a
PiperOrigin-RevId: 699989555
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants