> ## Content Index
> Fetch the complete content index at: https://datajutsu.com/llms.txt
> Use this file to discover other available public pages before exploring further.

# An Unknown Protobuf Enum Value Is a Number (and the JSON Output Is Where It Changes Type)
- URL: https://datajutsu.com/protobuf-unknown-enum-values/
- Published: 2026-10-23T06:52:30.000Z
- Updated: 2026-10-23T06:52:30.000Z
- Author: Data Jutsu

An enum in protobuf is a varint, and the number on the wire is the value. The list of member names in the schema is a label for the number, not a gate. I encoded 9 into a field at number 4 whose schema declares only RED=1 and BLUE=5 and got 2009, the field tag then the varint 9, and nothing checked the 9\. A repeated field holding 9, 5 and 1 encodes as 0809 0805 0801 and decodes back to all three, and a negative unknown value survives the same way: minus one signs itself as the ten-byte varint and the decoder hands back minus one. The format carries the number; the schema only explains the ones it knows.

The signature of an unknown value is in the JSON output, and it is a type change. A decoder with the enum-to-name mapping on writes a known member as the name string, so 1 comes back as RED in quotes. The same field, the same decoder, with a 9 on the wire writes a number: 9, not a string, no error. The field switches type in the output depending on whether that value is in the schema, which makes the output itself the detector. If you are looking at a number where a name should be, the sender used a value your schema does not have. Zero keeps its own nuance: an explicit zero on the wire shows up in the output as zero, and a field that was never written shows up as nothing at all, so zero and absent are two different things that both read as nothing in a generated default.

The two encoders disagree about the door you walk in through. The JS library accepts an unknown number: fromObject with the field set to 9 encodes 2009 without a word. It also takes an unknown name, by dropping it: the field set to the string PURPLE encodes the message without the field, siblings intact, no error, the round trip completes. A numeric string, the field set to the quoted nine, gets dropped too, because it is a string and the library does not parse strings into numbers. The C++ encoder inverts both: number 9 is accepted, and the name PURPLE is rejected with a named error, unknown enumeration value of PURPLE for field e. Same input, two doors, and one of the failures is the kind you never hear.

The silent drop is the one that costs. The message encodes, the other fields are present, the wire is valid, and the only trace is that a field which was set on the sending side is missing on the receiving side, and the decoder cannot tell that apart from the sender never having set it. That is the bug that shows up a week later as a missing value in a log, with the bytes in between looking completely innocent all the way through. The door that rejects loudly is the easy one, because the error names the field. The one that drops has to be caught by comparing what you sent with what came back, and that comparison is the whole reason a verify round trip exists.

For the code a generator hands you, the closed list versus the open wire is the entire story. The generated client has an enum that is a closed list copied from the schema, and a 9 arriving on the wire is an unknown member 9 in that code, whether it becomes an error, a default or a raw number depending on the language's generated path. That is why the diff tab lists a removed enum member as breaking: the old bytes now land in the default or the unknown branch. A member whose number changed is the same-wire silent reinterpret, the tag and the varint length do not move, only the label does. Adding a member is the safe direction: the new code knows the name, and the old code reads the number, which is survivable.

The tool covers this in three places. The decode tab is where the number shows up where a name should, which is the signature you are looking for. The raw decode tab shows the varint with no schema at all, so the family is visible before any label is. The diff tab lists the removal, the addition and the value change, each with its line of why. The converter this post measured is at [proto.datajutsu.com](https://proto.datajutsu.com/?ref=datajutsu.com), the tag and varint math underneath is in the [wire format post](https://datajutsu.com/how-protobuf-wire-format-works/), and the removed-member and changed-value lines are in the [breaking changes post](https://datajutsu.com/protobuf-breaking-changes/).