{"record":{"id":"e6b449c6e3d39a69","repo":"can1357/oh-my-pi","slug":"unsupported-protobuf-wire-type-wiretype-at-byte","errorCode":null,"errorMessage":"Unsupported protobuf wire type ${wireType} at byte ${reader.pos}","messagePattern":"Unsupported protobuf wire type (.+?) at byte (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/catalog/src/discovery/protobuf.ts","lineNumber":262,"sourceCode":"\t\t\tf.encode(value, writer);\n\t\t}\n\t\twriteUnknownFields(value, writer);\n\t\treturn writer.finish();\n\t};\n\n\tcodec.decode = (value: Uint8Array): T => {\n\t\tconst reader = new Reader(value);\n\t\tconst message = (typeName ? { $typeName: typeName } : {}) as T;\n\t\tfor (const f of compiledFields) {\n\t\t\tf.initDefault(message);\n\t\t}\n\n\t\twhile (reader.pos < reader.len) {\n\t\t\tconst tag = reader.uint32();\n\t\t\tconst fieldNumber = tag >>> 3;\n\t\t\tconst wireType = tag & 7;\n\t\t\tif (!isWireType(wireType)) {\n\t\t\t\tthrow new Error(`Unsupported protobuf wire type ${wireType} at byte ${reader.pos}`);\n\t\t\t}\n\t\t\tconst field = byNumber.get(fieldNumber);\n\t\t\tif (field) {\n\t\t\t\tfield.decode(message, reader, wireType, fieldNumber);\n\t\t\t} else {\n\t\t\t\tconst start = reader.pos;\n\t\t\t\treader.skip(wireType);\n\t\t\t\tappendUnknownField(message, {\n\t\t\t\t\tno: fieldNumber,\n\t\t\t\t\twireType,\n\t\t\t\t\tdata: reader.slice(start, reader.pos),\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\t\treturn message;\n\t};\n\n\tcodec.toJson = (value: T): JsonValue => {","sourceCodeStart":244,"sourceCodeEnd":280,"githubUrl":"https://github.com/can1357/oh-my-pi/blob/969062200754ea02cfac922e5ebb8c608c079e15/packages/catalog/src/discovery/protobuf.ts#L244-L280","documentation":"Thrown by the compiled protobuf codec while scanning a message: the tag's low 3 bits encode a wire type outside the set the codec understands (0 varint, 1 64-bit, 2 length-delimited, 5 32-bit). This means the bytes are not a valid message for this schema — either the payload is corrupt/truncated, or it's not protobuf at all.","triggerScenarios":"getCodec(...).decode on a buffer where a field tag decodes to wire type 3/4/6/7 (deprecated group start/end or garbage), typically from feeding the decoder non-protobuf bytes, a wrong message's bytes, or a mid-stream truncated buffer.","commonSituations":"Decoding an HTTP response body that is actually JSON/HTML (proxy error page) instead of protobuf; parsing a concatenated stream without length prefixes; offsetting into the buffer past the message start.","solutions":["Verify the bytes being decoded are actually protobuf (log the first bytes; JSON starts with '{', HTML with '<').","Check you're decoding the correct message type/scheme for this endpoint's response.","Ensure the buffer is complete — wire type 3/4 can appear when reading past a truncated message.","Capture the raw response and re-run it through `protoc --decode_raw` to identify the real field layout."],"exampleFix":"// before: decoding whatever came back\nconst msg = codec.decode(new Uint8Array(await res.arrayBuffer()));\n// after: guard content type first\nif (!res.headers.get(\"content-type\")?.includes(\"protobuf\")) throw new Error(\"unexpected response\");\nconst msg = codec.decode(new Uint8Array(await res.arrayBuffer()));","handlingStrategy":"try-catch","validationCode":"// sanity-check the payload looks like protobuf before decoding\nfunction looksProtobuf(buf: Uint8Array): boolean {\n  if (buf.length === 0) return false;\n  const first = buf[0];\n  return first !== 0x7b /* '{' */ && first !== 0x3c /* '<' */;\n}","typeGuard":"function isUint8Array(v: unknown): v is Uint8Array {\n  return v instanceof Uint8Array;\n}","tryCatchPattern":"try {\n  const msg = codec.decode(bytes);\n} catch (err) {\n  if (err.message.startsWith(\"Unsupported protobuf wire type\")) {\n    throw new Error(`payload is not valid protobuf for this schema (first bytes: ${[...bytes.slice(0, 8)]})`);\n  }\n  throw err;\n}","preventionTips":["Check the response content-type is protobuf before decoding.","Never decode error pages / JSON responses from proxies as protobuf.","Decode complete length-framed messages, not mid-stream slices."],"tags":["protobuf","decoding","binary","discovery"],"backgroundTag":"invalid-protobuf-wire-type","analyzedSha":"969062200754ea02cfac922e5ebb8c608c079e15","analyzedAt":"2026-08-31T10:29:35.737Z","schemaVersion":2},"datasetVersion":"2026-08-31T14:17:45.589Z"}