protobuf: Reject payloads missing proto2 required fields
A proto2 required field must be present in the payload. QtProtobuf
accepted an incomplete message and left the field at its default, so
data the reference implementation rejects outright was silently parsed
as valid.
Track which fields the payload supplied and report the missing required
ones once the message is complete. A counter would not do: a scalar may
legally repeat on the wire, which would hide a genuinely absent field.
Only the binary format enforces this. The reference implementation
accepts JSON that omits required fields, and being stricter would fail
conformance. Error::InvalidFormat is reused rather than adding an
enumerator, since QAbstractProtobufSerializer::Error is public API.
Missing required fields in submessages are reported too, because the
check runs per message as deserialization descends.
Not picked back: payloads that deserialize today start failing, and
there is no opt-out API to migrate to.
[ChangeLog][Important Behavior Changes][QtProtobuf] Deserializing the
binary format now fails with Error::InvalidFormat when a proto2 required
field is absent from the payload, matching the reference implementation.
Such payloads used to be accepted, leaving the field at its default.
JSON parsing stays tolerant, as it is upstream.
Fixes: QTBUG-150054
Change-Id: I281039029e3e5dcd3a5247e43d8bcd90c9c5ff00
Reviewed-by: Tatiana Borisova <tatiana.borisova@qt.io>