Skip to content

Use JSONDecodingOptions.ignoreUnknownFields to ignore unknown enums.#1345

Merged
thomasvl merged 2 commits intoapple:mainfrom
thomasvl:unknown_enums_json
Nov 15, 2022
Merged

Use JSONDecodingOptions.ignoreUnknownFields to ignore unknown enums.#1345
thomasvl merged 2 commits intoapple:mainfrom
thomasvl:unknown_enums_json

Conversation

@thomasvl
Copy link
Collaborator

A new conformance test came in protocolbuffers/protobuf@09f4901 that says ignoreUnknownFields should also result in unknown enums being ignored.

These changes are based on #896.

Fixes #972.

@thomasvl thomasvl requested a review from tbkka November 15, 2022 20:30
@tbkka
Copy link
Collaborator

tbkka commented Nov 15, 2022

Nice work! I think we might be missing a couple of test cases, but the core logic looks sound.

A new conformance test came in protocolbuffers/protobuf@09f4901 that says
ignoreUnknownFields should also result in unknown enums being ignored.

These changes are based on apple#896.

Fixes apple#972.
@tbkka
Copy link
Collaborator

tbkka commented Nov 15, 2022

Thank you for adding those. Looks all ready to go!

@thomasvl thomasvl merged commit 41684a8 into apple:main Nov 15, 2022
@thomasvl thomasvl deleted the unknown_enums_json branch November 15, 2022 21:09
@antongrbin antongrbin mentioned this pull request Jan 5, 2023
copybara-service bot pushed a commit to protocolbuffers/protobuf that referenced this pull request Mar 26, 2024
…wn_fields is set (#15887)

# Motivation

This PR fixes failing conformance tests for python with name `IgnoreUnknownEnumStringValue`.

The JSON parsing spec was discussed in #7392.

Recent equivalent changes for other languages:
* Swift: apple/swift-protobuf#1345
* C#: #15758

# Changes

- 1st commit is a noop  refactoring to make relevant _ConvertScalarFieldValue invocations localized
- 2nd commit introduces the child exception of `ParseError` named `EnumStringValueParseError` which is suppressed if `ignore_unknown_fields` is set
- 3rd commit updates the conformance test failure lists

Closes #15887

COPYBARA_INTEGRATE_REVIEW=#15887 from noom:anton/7392/fix-python-test fbcc93a
PiperOrigin-RevId: 619288323
elvisdukaj pushed a commit to elvisdukaj/protobuf that referenced this pull request Apr 3, 2024
…wn_fields is set (protocolbuffers#15887)

# Motivation

This PR fixes failing conformance tests for python with name `IgnoreUnknownEnumStringValue`.

The JSON parsing spec was discussed in protocolbuffers#7392.

Recent equivalent changes for other languages:
* Swift: apple/swift-protobuf#1345
* C#: protocolbuffers#15758

# Changes

- 1st commit is a noop  refactoring to make relevant _ConvertScalarFieldValue invocations localized
- 2nd commit introduces the child exception of `ParseError` named `EnumStringValueParseError` which is suppressed if `ignore_unknown_fields` is set
- 3rd commit updates the conformance test failure lists

Closes protocolbuffers#15887

COPYBARA_INTEGRATE_REVIEW=protocolbuffers#15887 from noom:anton/7392/fix-python-test fbcc93a
PiperOrigin-RevId: 619288323
deannagarcia pushed a commit to deannagarcia/protobuf that referenced this pull request Jun 20, 2024
…wn_fields is set (protocolbuffers#15887)

# Motivation

This PR fixes failing conformance tests for python with name `IgnoreUnknownEnumStringValue`.

The JSON parsing spec was discussed in protocolbuffers#7392.

Recent equivalent changes for other languages:
* Swift: apple/swift-protobuf#1345
* C#: protocolbuffers#15758

# Changes

- 1st commit is a noop  refactoring to make relevant _ConvertScalarFieldValue invocations localized
- 2nd commit introduces the child exception of `ParseError` named `EnumStringValueParseError` which is suppressed if `ignore_unknown_fields` is set
- 3rd commit updates the conformance test failure lists

Closes protocolbuffers#15887

COPYBARA_INTEGRATE_REVIEW=protocolbuffers#15887 from noom:anton/7392/fix-python-test fbcc93a
PiperOrigin-RevId: 619288323
copybara-service bot pushed a commit to protocolbuffers/protobuf 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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Issue parsing unknown enum case

2 participants