Repository navigation
pxf-android: skip a field whose wire type does not match its kind - #181
Merged
Merged
Conversation
LiteWireReader read every known field with its kind's reader, whatever wire type the tag carried. A mistyped field was then misread and the rest of the message with it: 3a050d01000000, an Int64Value whose field 1 arrives as fixed32, failed with 'invalid tag (zero)' where protowire-go and the full tier print i64_w = 0. The field is now skipped as unknown, in a message, a map entry and every well-known payload. A repeated packable field still takes either the packed or the unpacked record.
A map entry that lacks its key or its value, because the encoder left it out or because the reader now skips it as mistyped (#160), came back as the string "": by_int = { "": "x" } where protobuf-go prints { 0: "x" }, and stamps = { a: "" } where it prints the epoch. The missing field is now read from a zero encoding of its kind, so an integer key is 0, a bool key false, a message value empty and a well-known value its zero literal.
…mistyped fields (#160) 62 wire messages against text.proto, each with protowire-go's pb-text output for it: every wire type arriving on a field of another kind, in a message, a repeated field, a map entry and each well-known payload, plus packed and unpacked repeated records and map entries missing a key or a value. On main's reader 58 of the 63 tests fail.
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.
Fixes #160
The lite tier's wire reader now skips a field whose wire type does not match its declared kind, as protowire-go and the full tier do. Before, it read the field with its kind's reader anyway. The bytes got misread from there to the end of the message, so lite either rejected the message or printed a wrong value. For example,
3a050d01000000is anInt64Valuewhose field 1 arrives as fixed32. Lite rejected it withinvalid tag (zero), while Go printsi64_w = 0.What changed (
LiteWireReader)skipField, as an unknown field would be.pxf.BigInt,Decimal,BigFloatandSecret. InreadDecimalthat is a one-line change to theswitchexpression. It touches no other part of the method.Also fixed (its own commit, a consequence of the above)
"". The case shows up whenever a mistyped key or value is skipped, and also when an encoder leaves it out.by_int = { "": "x" }is now{ 0: "x" }, andstamps = { a: "" }is now{ a: 1970-01-01T00:00:00Z }, matching Go.Evidence
--format pb-text --schema text.v1.WellKnownagainst the spec'stestdata/text/text.proto:check-decode-androidprintedreject: 1:1: malformed wire: Protocol message contained an invalid tag (zero).and exited 1. Gocheck_decode(protowire-go 7465f91) printedi64_w = 0and exited 0. The full tiercheck-decodeprintedi64_w = 0and exited 0.check-decode-androidprintsi64_w = 0and exits 0.pxf-android-codegen-itWireTypeLiteTest: 63 tests, with the expected text taken from Go's output. With main'sLiteWireReaderput back, 58 of the 63 fail. The 5 that pass are the controls../gradlew build: BUILD SUCCESSFUL. Summed from the test-result XML: 780 tests, 0 failures, 0 errors, 0 skipped.cross_text_check.sh(protowire 09f5653; Go, java, java-lite):Ran 168 (port, case) pairs across 3 ports. ✓ Every port that ran writes the golden text.The builds used the plugin ref pinned in
gradle.properties(-PpxfJavaMeta.repo=<nonexistent>). The sibling../protowirecheckout is on another branch, and its plugin currently generatesSbeTextSbeMetacode that does not compile.Filed
2800givesf_int32 = 0), which Go and the full tier leave out. This is about field presence, not wire type, so it is not in this PR.