VictoriaMetrics/VictoriaMetrics · error
cannot read sum
Error message
cannot read sum
What it means
Case 6 (field 'sum', double) failed: fc.Double() returned ok=false so the parser cannot extract the sum value from the wire. As with the other numeric fields, malformed wire data causes an immediate abort of the whole Sketch message.
Source
Thrown at lib/protoparser/datadogsketches/parser.go:294
return fmt.Errorf("cannot read count")
}
d.Cnt = cnt
case 3:
v, ok := fc.Double()
if !ok {
return fmt.Errorf("cannot read min")
}
d.Min = v
case 4:
v, ok := fc.Double()
if !ok {
return fmt.Errorf("cannot read max")
}
d.Max = v
case 6:
sum, ok := fc.Double()
if !ok {
return fmt.Errorf("cannot read sum")
}
d.Sum = sum
case 7:
var ok bool
d.K, ok = fc.UnpackSint32s(d.K)
if !ok {
return fmt.Errorf("cannot read k")
}
case 8:
var ok bool
d.N, ok = fc.UnpackUint32s(d.N)
if !ok {
return fmt.Errorf("cannot read n")
}
}
}
return nil
}View on GitHub (pinned to 5079fb58f1)
Solutions
- Verify the payload with protoc --decode using the datadog agent proto definitions
- Correct the client serializer so sum is a double (wire type 1, 8 bytes)
- Test with the official Datadog agent pointed at the VM endpoint to isolate sender bugs
- Update VictoriaMetrics to the latest version
Defensive patterns
Strategy: validation
Validate before calling
// Validate sum is 8-byte fixed64 double in the payload before sending buf := new(bytes.Buffer) binary.Write(buf, binary.LittleEndian, math.Float64bits(sum)) // reference encoding
Try / catch
if err := stream.Parse(r, callback); err != nil {
if strings.Contains(err.Error(), "cannot read sum") { /* fix encoder */ }
} Prevention
- Serialize with proto.Marshal, never manual byte assembly
- Verify payloads with protoc --decode
- Monitor vm_protoparser_rows_unparsed_total{type="datadogsketches"}
When it happens
Trigger: Sketch payload where field 6 is truncated or encoded with a non-fixed64 wire type, e.g. by a client that serializes sum incorrectly.
Common situations: Custom exporters hand-encoding the Dogsketches protobuf, corrupted traffic through gateways, or mixing protocol versions between sender and VM.
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 VictoriaMetrics/VictoriaMetrics@5079fb58f1 (2026-09-03).
Data as JSON: /api/errors/983d036564d8d29b.
Report an issue: GitHub.