chenhg5/cc-connect · warning
yuanbao: empty data
Error message
yuanbao: empty data
What it means
parseFields is the low-level protobuf wire-format decoder for yuanbao frames; it rejects empty input with this error because there are no fields to parse. It indicates an upstream frame/message body that should contain data arrived empty.
Source
Thrown at platform/yuanbao/proto.go:133
func encodeConnMsgFull(cmdType int, cmd string, seqNo int, msgID string, module string, data []byte, needAck bool) []byte {
b := newBuffer(128 + len(data))
headBytes := (&buffer{}).writeHead(cmdType, cmd, seqNo, msgID, module, needAck, 0)
b.writeBytesField(1, headBytes)
if len(data) > 0 {
b.writeBytesField(2, data)
}
return b.bytes()
}
type field struct {
fieldNum int
wireType int
value interface{}
}
func parseFields(data []byte) ([]field, error) {
if len(data) == 0 {
return nil, fmt.Errorf("yuanbao: empty data")
}
var fields []field
pos := 0
for pos < len(data) {
tag, n := decodeVarint(data[pos:])
if n == 0 {
return nil, fmt.Errorf("yuanbao: parse varint tag failed at %d", pos)
}
pos += n
fieldNum := int(tag >> 3)
wt := int(tag & 0x07)
switch wt {
case wtVarint:
val, n := decodeVarint(data[pos:])
if n == 0 {
return nil, fmt.Errorf("yuanbao: parse varint at %d", pos)
}
fields = append(fields, field{fieldNum, wt, val})View on GitHub (pinned to 4000b2338a)
Solutions
- Log the raw frame before decoding to see whether the server genuinely sent an empty body
- Check the decompress/decrypt step upstream — empty output there usually means wrong key or corrupt payload
- Guard decode paths to skip parseFields when the payload is legitimately empty (e.g. pure ack frames)
- Retry the connection if the server persistently sends malformed frames
Example fix
// before
fields, err := parseFields(body)
// after
if len(body) == 0 { return nil } // empty ack frame, nothing to parse
fields, err := parseFields(body) Defensive patterns
Strategy: try-catch
Validate before calling
if len(data) == 0 { return nil /* nothing to parse */ } Try / catch
fields, err := parseFields(data); if err != nil { if strings.Contains(err.Error(), "empty data") { return nil /* tolerate empty frames */ }; return fmt.Errorf("decode: %w", err) } Prevention
- Skip empty payloads before invoking decoders
- Log raw frames at debug level to diagnose empty bodies
- Verify decrypt/decompress output is non-empty before parsing
- Add decode tests covering empty and truncated frames
When it happens
Trigger: decodeConnMsg, decodeAuthBindRsp, decodeInboundPush, or decodeMsgBodyElement passing a zero-length byte slice into parseFields — e.g. an empty push payload from the server or a failed decrypt/decompress yielding no bytes.
Common situations: Server sends a heartbeat/ack frame with an empty body that the decoder incorrectly routes through a decode path expecting data; decompression or decryption step produced empty output; truncated network frame.
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
- yuanbao: parse varint tag failed at %d
- yuanbao: parse varint at %d
- yuanbao: parse length at %d
- yuanbao: length %d exceeds data at %d
- yuanbao: 64-bit truncated at %d
AI-assisted analysis of chenhg5/cc-connect@4000b2338a (2026-09-06).
Data as JSON: /api/errors/d1fe070b40f627c0.
Report an issue: GitHub.