{"record":{"id":"caae77d1dac77846","repo":"can1357/oh-my-pi","slug":"unsupported-wire-type-wiretype-in-struct","errorCode":null,"errorMessage":"Unsupported wire type ${wireType} in Struct","messagePattern":"Unsupported wire type (.+?) in Struct","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/catalog/src/discovery/protobuf.ts","lineNumber":1029,"sourceCode":"\t\t\t\tassertWireType(wireType, 2);\n\t\t\t\tvalue = readJsonList(new Reader(reader.bytes()));\n\t\t\t\tbreak;\n\t\t\tdefault:\n\t\t\t\treader.skip(wireType);\n\t\t\t\tbreak;\n\t\t}\n\t}\n\treturn value;\n}\n\nfunction readJsonStruct(reader: Reader): { [key: string]: JsonValue } {\n\tconst output: { [key: string]: JsonValue } = {};\n\twhile (reader.pos < reader.len) {\n\t\tconst tag = reader.uint32();\n\t\tconst fieldNumber = tag >>> 3;\n\t\tconst wireType = tag & 7;\n\t\tif (!isWireType(wireType)) {\n\t\t\tthrow new Error(`Unsupported wire type ${wireType} in Struct`);\n\t\t}\n\t\tif (fieldNumber === 1) {\n\t\t\tassertWireType(wireType, 2);\n\t\t\tconst entryReader = new Reader(reader.bytes());\n\t\t\tlet entryKey = \"\";\n\t\t\tlet entryVal: JsonValue = null;\n\t\t\twhile (entryReader.pos < entryReader.len) {\n\t\t\t\tconst entryTag = entryReader.uint32();\n\t\t\t\tconst entryNo = entryTag >>> 3;\n\t\t\t\tconst entryWire = entryTag & 7;\n\t\t\t\tif (entryNo === 1) {\n\t\t\t\t\tentryKey = entryReader.string();\n\t\t\t\t} else if (entryNo === 2) {\n\t\t\t\t\tentryVal = readJsonValue(new Reader(entryReader.bytes()));\n\t\t\t\t} else if (isWireType(entryWire)) {\n\t\t\t\t\tentryReader.skip(entryWire);\n\t\t\t\t}\n\t\t\t}","sourceCodeStart":1011,"sourceCodeEnd":1047,"githubUrl":"https://github.com/can1357/oh-my-pi/blob/969062200754ea02cfac922e5ebb8c608c079e15/packages/catalog/src/discovery/protobuf.ts#L1011-L1047","documentation":"The manual protobuf decoder in the discovery layer throws this when it reads a field tag whose 3-bit wire type is not one of the wire types the decoder knows how to skip/parse (isWireType fails). Struct is a google.protobuf.Struct decoded by hand; an unknown wire type means the bytes do not match the expected protobuf encoding. This guards against corrupt or unexpectedly encoded payloads.","triggerScenarios":"Decoding a google.protobuf.Struct (e.g. from a discovery/catalog API response) whose bytes contain a field tag with wire type outside the supported set (0-5 are valid; anything else, e.g. 6 or 7, is malformed).","commonSituations":"Corrupted or truncated gRPC/protobuf responses, a proxy mangling binary bodies, or a new upstream encoding the decoder doesn't recognize.","solutions":["Inspect the raw response body for corruption or HTML/error pages injected into a binary protobuf stream","Verify the request is hitting the correct protobuf endpoint (not a JSON or HTML error page)","Update the catalog package; the decoder may not support a wire type the provider newly emits","Capture the payload and file a bug with the truncated hex dump"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n  const struct = decodeStruct(bytes);\n} catch (err) {\n  if (err instanceof Error && err.message.startsWith(\"Unsupported wire type\")) {\n    logger.warn(\"Malformed protobuf Struct payload; refetching\", { cause: err });\n    return refetch();\n  }\n  throw err;\n}","preventionTips":["Don't hand-modify or truncate binary protobuf bodies","Keep the catalog package updated for wire-type support changes","Validate that discovery endpoints return binary protobuf, not HTML error pages"],"tags":["protobuf","decoding","wire-type"],"backgroundTag":"protobuf-decode-failed","analyzedSha":"969062200754ea02cfac922e5ebb8c608c079e15","analyzedAt":"2026-08-31T10:29:35.737Z","schemaVersion":2},"datasetVersion":"2026-08-31T14:17:45.589Z"}