chenhg5/cc-connect · error

yuanbao: 64-bit truncated at

Error message

yuanbao: 64-bit truncated at %d

What it means

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.

Solutions

  1. Ensure the full frame body is received (buffer until the declared length is satisfied) before decoding.
  2. Check upstream framing: a dropped byte earlier will desync everything — log a hex dump around pos to locate the misalignment.
  3. Reconnect and re-request the message; truncated fixed64 data cannot be reconstructed.
  4. If fixed64 fields are newly appearing in server payloads, update the adapter's proto definitions.

Example fix

// before
cm, err := decodeConnMsg(chunk)
if err != nil {
    log.Fatal(err) // fatal on transient truncation
}
// after
cm, err := decodeConnMsg(chunk)
if err != nil {
    slog.Warn("yuanbao: dropping malformed frame", "err", err)
    conn.Reconnect() // resync rather than crash
    return
}
Defensive patterns

Strategy: try-catch

Type guard

func hasFixed64(b []byte, pos int) bool { return pos+8 <= len(b) }

Try / catch

cm, err := decodeConnMsg(raw)
if err != nil {
    slog.Warn("yuanbao: truncated fixed64, dropping frame", "err", err)
    return
}

Prevention

When it happens

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

Common situations: 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.

Understand the failure class

Background: "cannot parse invalid wire-format data", "cannot unmarshal", "failed unmarshalling": protobuf unmarshal errors explained — this error's family across 10 libraries.

Related errors


AI-assisted analysis of chenhg5/cc-connect@4000b2338a (2026-09-06). Data as JSON: /api/errors/0a77010d2b2b174c. Report an issue: GitHub.

Appendix: source

Thrown at platform/yuanbao/proto.go:168

			}
			fields = append(fields, field{fieldNum, wt, val})
			pos += n
		case wtLen:
			ln, n := decodeVarint(data[pos:])
			if n == 0 {
				return nil, fmt.Errorf("yuanbao: parse length at %d", pos)
			}
			pos += n
			if pos+int(ln) > len(data) {
				return nil, fmt.Errorf("yuanbao: length %d exceeds data at %d", ln, pos)
			}
			val := make([]byte, ln)
			copy(val, data[pos:pos+int(ln)])
			fields = append(fields, field{fieldNum, wt, val})
			pos += int(ln)
		case wt64Bit:
			if pos+8 > len(data) {
				return nil, fmt.Errorf("yuanbao: 64-bit truncated at %d", pos)
			}
			fields = append(fields, field{fieldNum, wt, binary.LittleEndian.Uint64(data[pos : pos+8])})
			pos += 8
		case wt32Bit:
			if pos+4 > len(data) {
				return nil, fmt.Errorf("yuanbao: 32-bit truncated at %d", pos)
			}
			fields = append(fields, field{fieldNum, wt, uint64(binary.LittleEndian.Uint32(data[pos : pos+4]))})
			pos += 4
		default:
			return nil, fmt.Errorf("yuanbao: unknown wire type %d at %d", wt, pos)
		}
	}
	return fields, nil
}

func decodeVarint(data []byte) (uint64, int) {
	var result uint64

View on GitHub (pinned to 4000b2338a)