Add check for fields not existing when writing container - #162
Closed
u9g wants to merge 2 commits into
Closed
Conversation
Contributor
|
Interpreter should probably be updated also |
A field typed void, switch, option, or a type protodef does not define may legitimately be undefined; only the builtin value types are checked.
This was referenced Sep 8, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
There is a common problem that when the protocol gets updated some fields are silently writing garbage, so let's try to catch that.
Compiled container writes throw
Missing field 'x'when a field is undefined and its type is one of protodef's value types: the numeric types,varint,bool,pstring,cstring,buffer,bitfield,mapper,array,count,container, or an alias of one. Bitfield members are always required.Fields typed
void,switch,option, or a type protodef does not define are not checked: those can encode an absent value (a switch whose default isvoid, prismarine-nbt's optional tags), and minecraft-protocol sends them undefined on purpose (use_entitywithmouse: 0, aSlotwithout NBT on 1.13-1.20.4).The interpreter is unchanged: it does not keep the JSON of a named type, so it cannot tell a switch alias from a varint alias.
minecraft-protocol's
packetTestseedsSpawnInfowithoutseaLevel(1.21.2+); that varint was written as 0 before and now fails thelogin/respawncases withMissing field 'seaLevel'.