Skip to content

Serializer: name the packet in write errors from a compiled protocol - #180

Open
u9g wants to merge 1 commit into
ProtoDef-io:masterfrom
u9g:serializer-packet-name
Open

u9g wants to merge 1 commit into
ProtoDef-io:masterfrom
u9g:serializer-packet-name

Conversation

@u9g

@u9g u9g commented Sep 8, 2026

Copy link
Copy Markdown
Contributor

Problem

Every packet write goes through Serializer.createPacketBuffer, but a compiled protocol never sets e.field, so the errors coming out say nothing about which packet failed:

Error: Write error for undefined : Missing field 'x'
Error: SizeOf error for undefined : 0 is not in the mappings value

The interpreter names it through the switch's field path (params.position.face); the compiler reports no path at all. The error is thrown inside _transform and surfaces asynchronously on the stream, so a caller cannot attribute it after the fact either.

Change

Serializer.createPacketBuffer prefixes the message with in packet <name>: when the value has a name and the error's field path does not already contain it:

in packet position: SizeOf error for undefined : up is not in the mappings value

Interpreted errors and values without a name are untouched.

Testing

  • New tests in test/misc.js: compiled gets the prefix, interpreted keeps its field path with no duplicate, a value with no name is left alone.
  • npm test: lint clean, 504 passing.

@extremeheat

Copy link
Copy Markdown
Contributor

Every packet write goes through Serializer.createPacketBuffer, but a compiled protocol never sets e.field, so the errors coming out say nothing about which packet failed:

Seems like correct fix is to fix that

@Pix3lPirat3

Copy link
Copy Markdown
Contributor

Nice, this is the packet-level half of the problem. I have a complementary branch that fills in the other half: it threads e.field through the compiled container read/write/sizeOf codegen (mirroring the interpreted tryDoc), so a compiled protocol produces a real dotted field path instead of undefined - e.g. SizeOf error for meta.label rather than SizeOf error for undefined. It stacks cleanly with this PR (your in packet <name>: prefix plus a populated field path -> in packet position: SizeOf error for meta.label), and it's what surfaces which field of a bedrock packet is missing/wrong (the recurring "bad_packet / SizeOf undefined" reports). Happy to open it as a follow-up on top of this once it lands, or fold it in here if you'd prefer. Verified with a nested round-trip matching the interpreted path exactly, full suite green + a regression test.

@rom1504 rom1504 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Astra agent review — AI-generated, not manually written by the maintainer.

The packet prefix improves context, but it still does not address extremeheat's request to populate the compiled field path. The later contributor reply offers the relevant container read/write/sizeOf work; coordinate it here or agree an explicit landing sequence before calling the underlying issue resolved.

Preserve interpreted behavior and verify nested failures report the actual field in both engines, then resolve the conflict. This is the current design/source assessment; no fresh complete suite was run.

Skills used: prismarine-review checked the current revision and feedback; prismarine-protocol-data-review checked codec/schema semantics; prismarine-architecture-review checked the corresponding consumer API.

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.

4 participants