{"record":{"id":"3777117b2c1217f1","repo":"chenhg5/cc-connect","slug":"yuanbao-unknown-wire-type-d-at-d","errorCode":null,"errorMessage":"yuanbao: unknown wire type %d at %d","messagePattern":"yuanbao: unknown wire type (.+?) at (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"platform/yuanbao/proto.go","lineNumber":179,"sourceCode":"\t\t\t}\n\t\t\tval := make([]byte, ln)\n\t\t\tcopy(val, data[pos:pos+int(ln)])\n\t\t\tfields = append(fields, field{fieldNum, wt, val})\n\t\t\tpos += int(ln)\n\t\tcase wt64Bit:\n\t\t\tif pos+8 > len(data) {\n\t\t\t\treturn nil, fmt.Errorf(\"yuanbao: 64-bit truncated at %d\", pos)\n\t\t\t}\n\t\t\tfields = append(fields, field{fieldNum, wt, binary.LittleEndian.Uint64(data[pos : pos+8])})\n\t\t\tpos += 8\n\t\tcase wt32Bit:\n\t\t\tif pos+4 > len(data) {\n\t\t\t\treturn nil, fmt.Errorf(\"yuanbao: 32-bit truncated at %d\", pos)\n\t\t\t}\n\t\t\tfields = append(fields, field{fieldNum, wt, uint64(binary.LittleEndian.Uint32(data[pos : pos+4]))})\n\t\t\tpos += 4\n\t\tdefault:\n\t\t\treturn nil, fmt.Errorf(\"yuanbao: unknown wire type %d at %d\", wt, pos)\n\t\t}\n\t}\n\treturn fields, nil\n}\n\nfunc decodeVarint(data []byte) (uint64, int) {\n\tvar result uint64\n\tvar shift uint\n\tfor i, b := range data {\n\t\tresult |= uint64(b&0x7F) << shift\n\t\tshift += 7\n\t\tif b&0x80 == 0 {\n\t\t\treturn result, i + 1\n\t\t}\n\t\tif shift >= 64 {\n\t\t\treturn 0, 0\n\t\t}\n\t}","sourceCodeStart":161,"sourceCodeEnd":197,"githubUrl":"https://github.com/chenhg5/cc-connect/blob/4000b2338aa6e850c99df54f8b0ed6ed7460b401/platform/yuanbao/proto.go#L161-L197","documentation":"Thrown by parseFields when a field tag carries a wire type outside the supported set {0 (varint), 1 (64-bit), 2 (length-delimited), 5 (32-bit)} — e.g. 3/4 (deprecated groups) or an impossible value. Either the server is sending protobuf features this hand-rolled decoder doesn't implement, or the cursor is desynchronized and reading mid-field bytes as a tag.","triggerScenarios":"Server starts using group fields (wire types 3/4) or a packed/new encoding not in the switch; or an earlier field's length was misparsed so the cursor lands on non-tag bytes producing a bogus wire type. Reached from all yuanbao decode paths.","commonSituations":"Yuanbao server protocol update introducing unsupported wire types; decoding non-protobuf bytes (e.g. a JSON or gzip body) as protobuf; frame boundary bugs causing desync.","solutions":["Log the wire type and offset; wire types 3/4 mean the server uses groups — extend parseFields to handle or skip SGROUP/EGROUP.","Verify the payload actually is raw protobuf (not gzipped/JSON) before decoding.","Resync from the frame boundary: reconnect or skip to the next frame after this error rather than continuing the stream.","Compare against a reference protobuf decode (protoc --decode_raw) of a captured frame to see what changed.","Pin/inspect the yuanbao server version for wire-format changes."],"exampleFix":"// before\ncase wt32Bit:\n    ...\ndefault:\n    return nil, fmt.Errorf(\"yuanbao: unknown wire type %d at %d\", wt, pos)\n// after\ncase wtSGROUP: // wire type 3: skip nested group until matching EGROUP\n    n, err := skipGroup(data[pos:], fieldNum)\n    if err != nil { return nil, err }\n    pos += n\ndefault:\n    return nil, fmt.Errorf(\"yuanbao: unknown wire type %d at %d\", wt, pos)","handlingStrategy":"try-catch","validationCode":null,"typeGuard":"func supportedWireType(wt int) bool {\n    switch wt { case 0, 1, 2, 5: return true }\n    return false\n}","tryCatchPattern":"fields, err := parseFields(data)\nif err != nil {\n    var werr *wireTypeError\n    if errors.As(err, &werr) && werr.WireType == 3 {\n        // extend decoder to support groups or upgrade adapter\n    }\n    stream.Resync()\n    return\n}","preventionTips":["Decode captured server frames with protoc --decode_raw when upgrading.","Never parse non-protobuf payloads with this codec.","Resync to frame boundaries after unknown wire types.","Keep the hand-rolled decoder's supported wire types documented."],"tags":["protobuf","wire-format","protocol-compat","yuanbao"],"backgroundTag":"protobuf-unmarshal-failed","analyzedSha":"4000b2338aa6e850c99df54f8b0ed6ed7460b401","analyzedAt":"2026-09-06T11:45:09.575Z","contentChangedAt":"2026-09-06T11:45:09.575Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}