Packed field with protoscope

51 views
Skip to first unread message

Andrei Pangratie

unread,
Aug 5, 2025, 6:53:37 AM Aug 5
to Protocol Buffers
Hello,

Something encoded with protoscope can't be decoded by protoscope, why?

$ echo '0: { 1 2 3 4 5 6 7 8 1 1 1 1 1 1 1 1 1 1 1}' | protoscope -s | xxd -ps
021301020304050607080101010101010101010101

$ echo 021301020304050607080101010101010101010101 | xxd -r -ps | protoscope
`021301020304050607080101010101010101010101`

I've compiled protoscope from here: https://github.com/protocolbuffers/protoscope.git commit 8e7a6aafa2c9958527b1e0747e66e1bfff045819. Is there a newer version of protoscope?

Em Rauch

unread,
Aug 5, 2025, 9:06:59 AM Aug 5
to Andrei Pangratie, Protocol Buffers
Packed fields and bytes fields use the same representation in the encoded wire format.

There's a bunch of cases where the interpretation is ambiguous without having a schema available (as in: the same exact byte sequence would be perfectly sensible to parse under different possible schemas). In those cases protoscope has to 'guess' what the type is based on some heuristics, so in the round trip that you are testing it can't really know if it was serialized as a bytes field or a packed field, and it just shows it as a bytes field in this case.

--
You received this message because you are subscribed to the Google Groups "Protocol Buffers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to protobuf+u...@googlegroups.com .
To view this discussion visit https://groups.google.com/d/msgid/protobuf/94703e12-5e56-4026-a6fc-bf8966dfd5fcn%40googlegroups.com .

Andrei Pangratie

unread,
Aug 5, 2025, 6:02:26 PM Aug 5
to Protocol Buffers
That makes sense, thanks.
Reply all
Reply to author
Forward
0 new messages