can1357/oh-my-pi · error

Unsupported wire type

Error message

Unsupported wire type ${wireType} in Struct

What it means

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.

Solutions

  1. Inspect the raw response body for corruption or HTML/error pages injected into a binary protobuf stream
  2. Verify the request is hitting the correct protobuf endpoint (not a JSON or HTML error page)
  3. Update the catalog package; the decoder may not support a wire type the provider newly emits
  4. Capture the payload and file a bug with the truncated hex dump
Defensive patterns

Strategy: try-catch

Try / catch

try {
  const struct = decodeStruct(bytes);
} catch (err) {
  if (err instanceof Error && err.message.startsWith("Unsupported wire type")) {
    logger.warn("Malformed protobuf Struct payload; refetching", { cause: err });
    return refetch();
  }
  throw err;
}

Prevention

When it happens

Trigger: 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).

Common situations: Corrupted or truncated gRPC/protobuf responses, a proxy mangling binary bodies, or a new upstream encoding the decoder doesn't recognize.

Related errors


AI-assisted analysis of can1357/oh-my-pi@9690622007 (2026-08-31). Data as JSON: /api/errors/caae77d1dac77846. Report an issue: GitHub.

Appendix: source

Thrown at packages/catalog/src/discovery/protobuf.ts:1029

				assertWireType(wireType, 2);
				value = readJsonList(new Reader(reader.bytes()));
				break;
			default:
				reader.skip(wireType);
				break;
		}
	}
	return value;
}

function readJsonStruct(reader: Reader): { [key: string]: JsonValue } {
	const output: { [key: string]: JsonValue } = {};
	while (reader.pos < reader.len) {
		const tag = reader.uint32();
		const fieldNumber = tag >>> 3;
		const wireType = tag & 7;
		if (!isWireType(wireType)) {
			throw new Error(`Unsupported wire type ${wireType} in Struct`);
		}
		if (fieldNumber === 1) {
			assertWireType(wireType, 2);
			const entryReader = new Reader(reader.bytes());
			let entryKey = "";
			let entryVal: JsonValue = null;
			while (entryReader.pos < entryReader.len) {
				const entryTag = entryReader.uint32();
				const entryNo = entryTag >>> 3;
				const entryWire = entryTag & 7;
				if (entryNo === 1) {
					entryKey = entryReader.string();
				} else if (entryNo === 2) {
					entryVal = readJsonValue(new Reader(entryReader.bytes()));
				} else if (isWireType(entryWire)) {
					entryReader.skip(entryWire);
				}
			}

View on GitHub (pinned to 9690622007)