VictoriaMetrics/VictoriaMetrics · error
cannot read KeyValueList
Error message
cannot read KeyValueList
What it means
In decodeAnyValueToJSON, field 6 of AnyValue is kvlist_value (an embedded KeyValueList message). If fc.MessageData() cannot extract a length-delimited message for that field, the decoder returns 'cannot read KeyValueList'. Like the ArrayValue case, this indicates the on-the-wire encoding does not match the AnyValue schema.
Source
Thrown at lib/protoparser/opentelemetry/pb/pb_json.go:112
doubleValue, ok := fc.Double()
if !ok {
return nil, fmt.Errorf("cannot read DoubleValue")
}
return a.NewNumberFloat64(doubleValue), nil
case 5:
data, ok := fc.MessageData()
if !ok {
return nil, fmt.Errorf("cannot read ArrayValue")
}
arr, err := decodeArrayValueToJSON(data, a, fb)
if err != nil {
return nil, fmt.Errorf("cannot decode ArrayValue: %w", err)
}
return arr, nil
case 6:
data, ok := fc.MessageData()
if !ok {
return nil, fmt.Errorf("cannot read KeyValueList")
}
obj, err := decodeKeyValueListToJSON(data, a, fb)
if err != nil {
return nil, fmt.Errorf("cannot decode KeyValueList: %w", err)
}
return obj, nil
case 7:
bytesValue, ok := fc.Bytes()
if !ok {
return nil, fmt.Errorf("cannot read BytesValue")
}
v := fb.formatBase64(bytesValue)
return a.NewString(v), nil
}
}
return a.NewNull(), nil
}
View on GitHub (pinned to 5079fb58f1)
Solutions
- Verify with protoc --decode_raw that kvlist_value is wire type 2 length-delimited.
- Correct the producer's encoding or regenerate it with an up-to-date OTLP proto.
- Check transport layers for truncation (Content-Length mismatches, proxy buffering limits).
- Isolate the failure to the single attribute instead of rejecting the entire request.
Defensive patterns
Strategy: validation
Validate before calling
// Ensure kvlist field is length-delimited before decoding
num, typ, n := protowire.ConsumeTag(src)
if n < 0 || typ != protowire.BytesType {
return errors.New("kvlist_value is not a length-delimited message")
} Type guard
func isMessageField(src []byte) bool {
_, typ, n := protowire.ConsumeTag(src)
return n >= 0 && typ == protowire.BytesType
} Prevention
- Regenerate protobuf code from current opentelemetry-proto definitions
- Validate wire types for oneof members in tests
- Guard public OTLP endpoints with payload validation
- Avoid manual byte-slicing of received messages
When it happens
Trigger: An AnyValue contains field 6 encoded with a non-length-delimited wire type (varint/fixed instead of wire type 2), or the message length prefix extends beyond the buffer.
Common situations: Hand-written protobuf in a custom exporter, corrupted or truncated spans/logs in transit, or replaying captured traffic whose buffers were sliced incorrectly.
Related errors
- cannot read DoubleValue
- cannot read ArrayValue
- cannot unmarshal ResourceMetrics: %w
- cannot read ScopeMetrics data
- cannot unmarshal ScopeMetrics: %w
AI-assisted analysis of VictoriaMetrics/VictoriaMetrics@5079fb58f1 (2026-09-03).
Data as JSON: /api/errors/70d51d50c2bca673.
Report an issue: GitHub.