Skip to content

Read Protobuf and MessagePack bodies - #13

Merged
tonytonycoder11 merged 7 commits into
mainfrom
protobuf-and-messagepack-decoders
Oct 24, 2026
Merged

tonytonycoder11 merged 7 commits into
mainfrom
protobuf-and-messagepack-decoders

Conversation

@tonytonycoder11

@tonytonycoder11 tonytonycoder11 commented Oct 24, 2026 •

Copy link
Copy Markdown
Contributor

Stacked on #12: its commits are in this branch, and GitHub moves the base to main when #12 is merged. The diff here is the decoders, plus the two commits at the end, which the last paragraph describes.

Protobuf and MessagePack bodies were a hex dump unless the app wrote a decoder. Both now have one, and the inspector registers the ones that need no schema.

MessagePack describes itself, so a body whose media type says MessagePack (application/msgpack, application/x-msgpack, application/vnd.msgpack, a +msgpack suffix) is shown as indented text with no setup. Integers keep every digit up to 64 bits, bytes are hex, a map with keys that are not strings has them written as text, and the timestamp extension is an ISO 8601 date.

Protobuf has two modes:

  • With FlutwireProtobufDecoder(descriptorSet: ...), which takes the descriptor set that protoc writes with --descriptor_set_out and --include_imports: fields by name and type, enums by name, maps as objects, packed and unpacked repeated numbers as lists, Timestamp and Duration as one string each, and fields the schema does not know by their number. messageType says which message a body is when it is not gRPC.
  • Without a schema, which the inspector registers after the decoders the app listed: fields by number, with a length delimited field taken for text, a message or bytes the way protoc --decode_raw takes it.

A gRPC or gRPC-web call (application/grpc or application/grpc-web, with or without +proto) finds its message types from the method in its address, lists the messages of a stream and shows the trailers. A compressed message is marked as such, because the decoder has no algorithm to run.

Both decoders leave a body alone when it was cut or does not end where its last value does. They run when a body is opened, so the capture is untouched, and they are plain Dart with no dart:io, so they work on the web. The wire reader keeps 64 bit numbers exact by moving from int to BigInt past 2^53.

I could not cross-check the Protobuf side against protoc here, because the Homebrew build fails to load abseil. The tests use messages and descriptors encoded by hand from the encoding guide and descriptor.proto, including the guide's own examples. A descriptor set from a real API is worth one run before 0.2.0.

I tried it on an Android emulator with the example app, which has a MessagePack body and a Protobuf body now. All four suites pass, flutter analyze --fatal-infos is clean and the example builds for the web.

The last two commits come from a review of #12 and of this branch, and neither changes behaviour. One compiles three regular expressions once instead of on every call and copies a cut message once instead of twice. The other gives the three files that import dart:io and did not say so (websocket_reader, wire_socket and disk_store) the _io suffix that the other five carry.

Targets 0.2.0, Tier 2, M22.

MessagePack describes itself, so a body whose media type says so needs no
schema. Integers keep every digit up to 64 bits, bytes are hex, a map with
keys that are not strings has them written as text, and a timestamp
extension is an ISO 8601 date. A body that was cut, or that does not end
where its last value does, is left to the hex dump.
With the descriptor set protoc writes, fields come out by name and type:
enums by name, maps as objects, packed and unpacked repeated numbers as
lists, a duration and a timestamp as one string, and fields the schema does
not know by their number. Without one they come out by field number, with a
length delimited field taken for text, a message or bytes the way
protoc --decode_raw takes it. A gRPC or gRPC-web call finds its message
types from the method in its address, lists the messages of a stream and
shows the trailers.
The viewer asks the decoders the app registered first, then MessagePack,
then Protobuf by field number. Decoding happens when a body is opened, so the
capture is untouched.
@tonytonycoder11 tonytonycoder11 moved this to In progress in Flutwire Oct 24, 2026
@trueup-by-nacode-studios

trueup-by-nacode-studios Bot commented Oct 24, 2026 •

Copy link
Copy Markdown

This pull request adds no capability the code did not already have.

31 files read · 2155 ms · against 3443b57 · engine 1.4.1

Base automatically changed from websocket-and-event-messages to main October 24, 2026 10:40
@tonytonycoder11
tonytonycoder11 merged commit 8b56bbc into main Oct 24, 2026
6 checks passed
@tonytonycoder11
tonytonycoder11 deleted the protobuf-and-messagepack-decoders branch October 24, 2026 12:10
@tonytonycoder11 tonytonycoder11 moved this from In progress to Shipped in Flutwire Oct 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Shipped

Development

Successfully merging this pull request may close these issues.

1 participant