VictoriaMetrics/VictoriaMetrics · error
cannot read AccountID
Error message
cannot read AccountID
What it means
MetricMetadata field 11 is 'AccountID' (uint32, a VictoriaMetrics extension field). fc.Uint32() returns ok=false when the field bytes are not a valid varint or the buffer ends mid-value. The library reports 'cannot read AccountID', indicating this extension field was encoded with a wrong wire type or truncated.
Source
Thrown at lib/prompb/write_request_unmarshaler.go:695
return fmt.Errorf("cannot read metric family name")
}
mm.MetricFamilyName = value
case 4:
value, ok := fc.String()
if !ok {
return fmt.Errorf("cannot read help")
}
mm.Help = value
case 5:
value, ok := fc.String()
if !ok {
return fmt.Errorf("cannot read unit")
}
mm.Unit = value
case 11:
value, ok := fc.Uint32()
if !ok {
return fmt.Errorf("cannot read AccountID")
}
mm.AccountID = value
case 12:
value, ok := fc.Uint32()
if !ok {
return fmt.Errorf("cannot read ProjectID")
}
mm.ProjectID = value
}
}
return nil
}
View on GitHub (pinned to 5079fb58f1)
Solutions
- Encode AccountID as a uint32 varint (field 11) per the VM-extended MetricMetadata schema.
- Regenerate the sender from the VictoriaMetrics prompb .proto so extension fields match.
- Check the body for truncation before decoding.
- Return 400 and log the payload region around the failure.
Example fix
// sender side: before — AccountID as bytes buf.EncodeStringBytes(11, []byte(accountID)) // after — uint32 varint buf.EncodeUint32(11, mm.AccountID)
Defensive patterns
Strategy: type-guard
Validate before calling
// VM extension fields: validate tenant IDs fit uint32 before encoding
func validAccountID(id uint32) bool {
return id > 0
}
if !validAccountID(mm.AccountID) {
return errors.New("AccountID must be a positive uint32")
} Type guard
func isVarintUint32Field(b []byte, fieldNum int) bool {
if len(b) < 1 {
return false
}
tag := b[0]
return int(tag>>3) == fieldNum && tag&0x7 == 0
} Try / catch
if err := wr.Unmarshal(body); err != nil {
if strings.Contains(err.Error(), "cannot read AccountID") {
http.Error(w, "invalid AccountID encoding in metadata", http.StatusBadRequest)
return
}
return err
} Prevention
- Regenerate senders from the VictoriaMetrics-extended prompb .proto so fields 11/12 match
- Encode tenant IDs as uint32 varint, never as bytes or fixed32
- In multi-tenant gateways, forward the body byte-for-byte rather than re-encoding
- Add round-trip tests that include AccountID/ProjectID extension fields
When it happens
Trigger: AccountID encoded as fixed32/bytes instead of varint, truncated buffer at field 11, or a sender mixing Prometheus-generated metadata (no fields 11/12) with a VictoriaMetrics-specific encoder.
Common situations: Cluster tenants sending custom-encoded metadata, truncated bodies in multi-tenant gateways, hand-rolled serializers writing the AccountID with the wrong type.
Related errors
- cannot read ProjectID
- cannot read sample value
- cannot read sample timestamp
- cannot read metric type
- cannot read metric family name
AI-assisted analysis of VictoriaMetrics/VictoriaMetrics@5079fb58f1 (2026-09-03).
Data as JSON: /api/errors/ed67b0ed2c29c6b9.
Report an issue: GitHub.