{"record":{"id":"52223f8fbc8ca348","repo":"can1357/oh-my-pi","slug":"unsupported-wire-type-entrywiretype-in-map-entr","errorCode":null,"errorMessage":"Unsupported wire type ${entryWireType} in map entry","messagePattern":"Unsupported wire type (.+?) in map entry","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/catalog/src/discovery/protobuf.ts","lineNumber":410,"sourceCode":"\t\t\t\t}\n\t\t\t\twriter.tag(number, 2);\n\t\t\t\twriter.lengthDelimited(entry.finish());\n\t\t\t}\n\t\t},\n\t\tdecode(message, reader, wireType, _fieldNumber) {\n\t\t\tassertWireType(wireType, 2);\n\t\t\tconst target = mapField(message, name);\n\t\t\tconst limit = reader.uint32();\n\t\t\tconst end = reader.pos + limit;\n\t\t\tlet entryKey = \"\";\n\t\t\tlet entryValue: unknown = valCodec.defaultValue;\n\n\t\t\twhile (reader.pos < end) {\n\t\t\t\tconst tag = reader.uint32();\n\t\t\t\tconst entryNumber = tag >>> 3;\n\t\t\t\tconst entryWireType = tag & 7;\n\t\t\t\tif (!isWireType(entryWireType)) {\n\t\t\t\t\tthrow new Error(`Unsupported wire type ${entryWireType} in map entry`);\n\t\t\t\t}\n\t\t\t\tif (entryNumber === 1) {\n\t\t\t\t\tassertWireType(entryWireType, key.wireType);\n\t\t\t\t\tentryKey = requireString(key.decode(reader));\n\t\t\t\t} else if (entryNumber === 2) {\n\t\t\t\t\tassertWireType(entryWireType, valCodec.wireType);\n\t\t\t\t\tentryValue = valCodec.decode(reader);\n\t\t\t\t} else {\n\t\t\t\t\treader.skip(entryWireType);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\ttarget[entryKey] = entryValue;\n\t\t},\n\t\ttoJson(message, output) {\n\t\t\tconst input = Reflect.get(message, name);\n\t\t\tif (!isMessageObject(input)) return;\n\t\t\tconst mapOutput: { [key: string]: JsonValue } = Object.create(null);","sourceCodeStart":392,"sourceCodeEnd":428,"githubUrl":"https://github.com/can1357/oh-my-pi/blob/969062200754ea02cfac922e5ebb8c608c079e15/packages/catalog/src/discovery/protobuf.ts#L392-L428","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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."],"exampleFix":"// before: slicing bytes manually\nconst entry = decodeMapEntry(buf.subarray(offset));\n// after: honor the length-delimited prefix\nconst len = buf[offset++]; // varint length as encoded\nconst entry = decodeMapEntry(buf.subarray(offset, offset + len));","handlingStrategy":"try-catch","validationCode":"null","typeGuard":"null","tryCatchPattern":"try {\n  const msg = codec.decode(bytes);\n} catch (err) {\n  if (err.message.includes(\"Unsupported wire type\") && err.message.includes(\"map entry\")) {\n    throw new Error(`map field bytes incompatible with codec schema — regenerate codec from current .proto`);\n  }\n  throw err;\n}","preventionTips":["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."],"tags":["protobuf","decoding","binary","map-field"],"backgroundTag":"invalid-protobuf-wire-type","analyzedSha":"969062200754ea02cfac922e5ebb8c608c079e15","analyzedAt":"2026-08-31T10:29:35.737Z","schemaVersion":2},"datasetVersion":"2026-08-31T14:17:45.589Z"}