Skip to content

pxf-android: print nothing for a plain field whose wire value is zero - #182

Merged
trendvidia merged 5 commits into
mainfrom
pxf-android/implicit-zero-180
Nov 3, 2026
Merged

trendvidia merged 5 commits into
mainfrom
pxf-android/implicit-zero-180

Conversation

@bfrancojr

Copy link
Copy Markdown
Collaborator

Fixes #180

When the lite tier reads PB bytes into text, it now prints nothing for a plain proto3 field whose wire value is zero, as protowire-go and the full tier do. For example, 2800 used to print f_int32 = 0 and now prints nothing.

Stacked on #181 (same file, LiteWireReader). The base is #181's branch, so the diff shows this change alone. Merge #181 first, and GitHub moves this PR onto main.

What changes

Evidence

  • Lite against Go on the issue's 13 rows (protowire-go main, check_decode --format pb-text): the 7 plain-zero rows, -0.0, two last-wins orders, a nested and a list-element message, and optional and map-entry controls.
  • New ImplicitZeroLiteTest: 13 tests, each expected text copied from Go's output. All pass.
  • ./gradlew build with the plugin fetched at main's pin: 793 tests, 0 failures, 0 skipped.
  • The write, text and security gates pass for go, java and java-lite.

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.
LiteWireReader turns each record it reads into text, so a plain proto3
field written as zero on the wire printed, where protowire-go and the
full tier, which read the bytes into a message first, print nothing
(#180). A singular field in implicitPresenceFields() whose last value is
its zero value is now dropped; -0.0, optional fields and map entries
keep theirs.
Base automatically changed from pxf-android/wire-type-160 to main November 3, 2026 10:59
@trendvidia
trendvidia merged commit af83446 into main Nov 3, 2026
4 checks passed
@trendvidia
trendvidia deleted the pxf-android/implicit-zero-180 branch November 3, 2026 19:12
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.

pxf-android: LiteWireReader prints a plain proto3 zero value that Go leaves out

2 participants