{"record":{"id":"0a77010d2b2b174c","repo":"chenhg5/cc-connect","slug":"yuanbao-64-bit-truncated-at-d","errorCode":null,"errorMessage":"yuanbao: 64-bit truncated at %d","messagePattern":"yuanbao: 64-bit truncated at (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"platform/yuanbao/proto.go","lineNumber":168,"sourceCode":"\t\t\t}\n\t\t\tfields = append(fields, field{fieldNum, wt, val})\n\t\t\tpos += n\n\t\tcase wtLen:\n\t\t\tln, n := decodeVarint(data[pos:])\n\t\t\tif n == 0 {\n\t\t\t\treturn nil, fmt.Errorf(\"yuanbao: parse length at %d\", pos)\n\t\t\t}\n\t\t\tpos += n\n\t\t\tif pos+int(ln) > len(data) {\n\t\t\t\treturn nil, fmt.Errorf(\"yuanbao: length %d exceeds data at %d\", ln, pos)\n\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","sourceCodeStart":150,"sourceCodeEnd":186,"githubUrl":"https://github.com/chenhg5/cc-connect/blob/4000b2338aa6e850c99df54f8b0ed6ed7460b401/platform/yuanbao/proto.go#L150-L186","documentation":"Thrown by parseFields when a 64-bit fixed-width field (wire type 1, wt64Bit) is present but fewer than 8 bytes remain in the buffer (pos+8 > len(data)). The decoder refuses to read a partial fixed64 value, so a truncated message aborts parsing.","triggerScenarios":"A frame whose final field is a fixed64 (timestamp, ID, etc.) is cut off before those 8 bytes arrive; or the parser cursor is desynchronized so it interprets trailing bytes as a wt64Bit tag near the buffer end. Reached via all yuanbao decode paths.","commonSituations":"Incomplete WebSocket frame delivery, wrong frame-length bookkeeping upstream, or garbage bytes at the tail of a misaligned parse landing on a wire-type-1 tag.","solutions":["Ensure the full frame body is received (buffer until the declared length is satisfied) before decoding.","Check upstream framing: a dropped byte earlier will desync everything — log a hex dump around pos to locate the misalignment.","Reconnect and re-request the message; truncated fixed64 data cannot be reconstructed.","If fixed64 fields are newly appearing in server payloads, update the adapter's proto definitions."],"exampleFix":"// before\ncm, err := decodeConnMsg(chunk)\nif err != nil {\n    log.Fatal(err) // fatal on transient truncation\n}\n// after\ncm, err := decodeConnMsg(chunk)\nif err != nil {\n    slog.Warn(\"yuanbao: dropping malformed frame\", \"err\", err)\n    conn.Reconnect() // resync rather than crash\n    return\n}","handlingStrategy":"try-catch","validationCode":null,"typeGuard":"func hasFixed64(b []byte, pos int) bool { return pos+8 <= len(b) }","tryCatchPattern":"cm, err := decodeConnMsg(raw)\nif err != nil {\n    slog.Warn(\"yuanbao: truncated fixed64, dropping frame\", \"err\", err)\n    return\n}","preventionTips":["Guarantee complete frame delivery before decode (length checks).","Drop and resync on any wire-format error; never continue mid-frame.","Monitor for protocol updates that introduce new fixed64 fields.","Write round-trip tests covering fixed-width fields at message end."],"tags":["protobuf","wire-format","truncated-data","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-14T00:17:10.932Z"}