can1357/oh-my-pi · error · Error
Unsupported wire type ${entryWireType} in map entry
Error message
Unsupported wire type ${entryWireType} in map entry What it means
Thrown while decoding a protobuf map<K,V> field: an entry's tag carries a wire type outside the supported set, so the entry cannot be parsed. As with the top-level wire-type error, this indicates corrupt, truncated, or non-protobuf bytes rather than a normal code path.
Source
Thrown at packages/catalog/src/discovery/protobuf.ts:410
}
writer.tag(number, 2);
writer.lengthDelimited(entry.finish());
}
},
decode(message, reader, wireType, _fieldNumber) {
assertWireType(wireType, 2);
const target = mapField(message, name);
const limit = reader.uint32();
const end = reader.pos + limit;
let entryKey = "";
let entryValue: unknown = valCodec.defaultValue;
while (reader.pos < end) {
const tag = reader.uint32();
const entryNumber = tag >>> 3;
const entryWireType = tag & 7;
if (!isWireType(entryWireType)) {
throw new Error(`Unsupported wire type ${entryWireType} in map entry`);
}
if (entryNumber === 1) {
assertWireType(entryWireType, key.wireType);
entryKey = requireString(key.decode(reader));
} else if (entryNumber === 2) {
assertWireType(entryWireType, valCodec.wireType);
entryValue = valCodec.decode(reader);
} else {
reader.skip(entryWireType);
}
}
target[entryKey] = entryValue;
},
toJson(message, output) {
const input = Reflect.get(message, name);
if (!isMessageObject(input)) return;
const mapOutput: { [key: string]: JsonValue } = Object.create(null);View on GitHub (pinned to 9690622007)
Solutions
- Confirm the buffer slice passed to the map decoder starts exactly at the entry boundary (check length-delimited offsets).
- Regenerate/re-sync the codec against the producer's current .proto — key/value field types may have changed.
- Validate the raw payload with `protoc --decode_raw` to see the actual entry structure.
- Wrap decoding with a clear error path so corrupt upstream payloads surface as data errors, not decoder crashes.
Example fix
// before: slicing bytes manually const entry = decodeMapEntry(buf.subarray(offset)); // after: honor the length-delimited prefix const len = buf[offset++]; // varint length as encoded const entry = decodeMapEntry(buf.subarray(offset, offset + len));
Defensive patterns
Strategy: try-catch
Validate before calling
null
Type guard
null
Try / catch
try {
const msg = codec.decode(bytes);
} catch (err) {
if (err.message.includes("Unsupported wire type") && err.message.includes("map entry")) {
throw new Error(`map field bytes incompatible with codec schema — regenerate codec from current .proto`);
}
throw err;
} Prevention
- Keep the codec generated from the producer's current .proto version.
- Slice map entries using the exact length-delimited boundaries, never fixed offsets.
- Log raw bytes on decode failure to distinguish corruption from schema drift.
When it happens
Trigger: decode of a map field where the embedded entry message's bytes are malformed — wrong offset into the entry, bytes from a different schema version where field 1/2 changed, or garbage bytes misread as an entry tag.
Common situations: Server/producer wrote map entries with a newer schema (changed key/value types); decoding a slice that starts mid-entry; response intercepted/modified by a proxy.
Related errors
- Unsupported protobuf wire type ${wireType} at byte ${reader.
- Unsupported wire type ${wireType} in Struct
- Unsupported wire type ${wireType} in ListValue
- invalid byte sequence: {:02x?}
- Unknown oneof field ${fieldNumber}
AI-assisted analysis of can1357/oh-my-pi@9690622007 (2026-08-31).
Data as JSON: /api/errors/52223f8fbc8ca348.
Report an issue: GitHub.