Commit 014f676
Fix JSON printing of Any of an empty message in C++Proto.
This check was likely based on confusion about presence: if the 'bytes' field of Any supported presence and was unset it would be a malformed message.
However, as a Proto3 message the bytes field is implicit presence, and an empty message serializes to 0-bytes. It is perfectly valid to pack an empty message into an Any, and there's no distinguishing between "they forgot to set the value" and "actual zero-length serialization".
This wasn't caught by a user sooner since it is already allowed when allow_legacy_nonconformant_behavior is on, and that setting is on by default and rarely disabled.
#24937
PiperOrigin-RevId: 8482533571 parent dd7c6f8 commit 014f676
2 files changed
+17
-3
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
745 | 745 | | |
746 | 746 | | |
747 | 747 | | |
748 | | - | |
749 | | - | |
750 | | - | |
751 | 748 | | |
752 | 749 | | |
753 | 750 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1179 | 1179 | | |
1180 | 1180 | | |
1181 | 1181 | | |
| 1182 | + | |
| 1183 | + | |
| 1184 | + | |
| 1185 | + | |
| 1186 | + | |
| 1187 | + | |
| 1188 | + | |
| 1189 | + | |
| 1190 | + | |
| 1191 | + | |
| 1192 | + | |
| 1193 | + | |
| 1194 | + | |
| 1195 | + | |
| 1196 | + | |
| 1197 | + | |
| 1198 | + | |
1182 | 1199 | | |
1183 | 1200 | | |
1184 | 1201 | | |
| |||
0 commit comments