{"record":{"id":"b45061242c152dd5","repo":"VictoriaMetrics/VictoriaMetrics","slug":"cannot-unmarshal-positive-w","errorCode":null,"errorMessage":"cannot unmarshal Positive: %w","messagePattern":"cannot unmarshal Positive: %w","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"lib/protoparser/opentelemetry/pb/pb.go","lineNumber":1377,"sourceCode":"\t\t\t}\n\t\t\tehctx.hasSum = true\n\t\tcase 6:\n\t\t\tehctx.scale, ok = fc.Sint32()\n\t\t\tif !ok {\n\t\t\t\treturn fmt.Errorf(\"cannot read Scale\")\n\t\t\t}\n\t\tcase 7:\n\t\t\tehctx.zeroCount, ok = fc.Fixed64()\n\t\t\tif !ok {\n\t\t\t\treturn fmt.Errorf(\"cannot read ZeroCount\")\n\t\t\t}\n\t\tcase 8:\n\t\t\tdata, ok := fc.MessageData()\n\t\t\tif !ok {\n\t\t\t\treturn fmt.Errorf(\"cannot read Positive buckets\")\n\t\t\t}\n\t\t\tif err := ehctx.positive.decodeBuckets(data); err != nil {\n\t\t\t\treturn fmt.Errorf(\"cannot unmarshal Positive: %w\", err)\n\t\t\t}\n\t\tcase 9:\n\t\t\tdata, ok := fc.MessageData()\n\t\t\tif !ok {\n\t\t\t\treturn fmt.Errorf(\"cannot read Negative buckets\")\n\t\t\t}\n\t\t\tif err := ehctx.negative.decodeBuckets(data); err != nil {\n\t\t\t\treturn fmt.Errorf(\"cannot unmarshal Negative: %w\", err)\n\t\t\t}\n\t\tcase 10:\n\t\t\tehctx.flags, ok = fc.Uint32()\n\t\t\tif !ok {\n\t\t\t\treturn fmt.Errorf(\"cannot read Flags\")\n\t\t\t}\n\t\tcase 12:\n\t\t\tehctx.min, ok = fc.Double()\n\t\t\tif !ok {\n\t\t\t\treturn fmt.Errorf(\"cannot read Min\")","sourceCodeStart":1359,"sourceCodeEnd":1395,"githubUrl":"https://github.com/VictoriaMetrics/VictoriaMetrics/blob/5079fb58f1e8e62113f90c945ad71586c797d770/lib/protoparser/opentelemetry/pb/pb.go#L1359-L1395","documentation":"Wrap of the error returned by buckets.decodeBuckets when unmarshaling the `positive` Buckets submessage (field 8) of an ExponentialHistogramDataPoint. The embedded message bytes were obtained, but their internal fields (offset / bucket_counts) could not be parsed. The wrapped error names the exact inner field that failed.","triggerScenarios":"Parsing OTLP metrics where the positive Buckets submessage contains field 1 (offset) or field 2 (bucket_counts) with an unexpected wire type, or the submessage bytes are internally truncated so NextField fails.","commonSituations":"Version drift between producers and consumers of opentelemetry-proto (a field repurposed with a different type), corrupted telemetry queues, or fuzz/hand-written exporters emitting malformed bucket data.","solutions":["Inspect the wrapped inner error to see which bucket field failed, then fix the producer serialization for that field.","Re-send the batch; if reproducible, decode the payload with google.golang.org/protobuf to confirm the message is invalid per the proto spec.","Align opentelemetry-proto versions between the SDK/collector emitting metrics and the ingestion endpoint.","If you are writing the exporter yourself, use the generated proto marshalers instead of hand-packing bucket fields."],"exampleFix":"// before: hand-packed buckets with varint wire type for field 1\nmm.AppendInt32(1, buckets.Offset)\n// after: offset is sint32 in proto; use the generated marshaler\nbucketMsg := &metricspb.ExponentialHistogramDataPoint_Buckets{Offset: buckets.Offset, BucketCounts: buckets.Counts}\nmm.AppendMessage(8) // then marshal bucketMsg into it","handlingStrategy":"try-catch","validationCode":"// Pre-validate with the generated types, which check nested Buckets fields too\nvar req metricspb.ExportMetricsServiceRequest\nif err := proto.Unmarshal(payload, &req); err != nil {\n    return fmt.Errorf(\"invalid OTLP payload: %w\", err)\n}","typeGuard":null,"tryCatchPattern":"if err := decode(data); err != nil {\n    var inner error\n    if errors.Unwrap(err) != nil {\n        inner = errors.Unwrap(err) // reveals which bucket field failed\n    }\n    log.Error(\"failed to decode positive buckets\", \"wrapped\", inner)\n    metrics.MalformedPayloads.Inc()\n    return nil // skip instead of failing the whole request\n}","preventionTips":["Use generated proto marshalers (AppendSint32/AppendUint64) rather than manual field packing","Version-lock opentelemetry-proto across the pipeline","Monitor for this error rate as an indicator of a broken upstream exporter","Checksum payloads when storing/replaying them through queues"],"tags":["protobuf","otlp","histogram","malformed-payload"],"backgroundTag":"protobuf-decode-failed","analyzedSha":"5079fb58f1e8e62113f90c945ad71586c797d770","analyzedAt":"2026-09-03T18:10:26.153Z","contentChangedAt":"2026-09-03T18:10:26.153Z","schemaVersion":2},"datasetVersion":"2026-09-08T15:18:49.778Z"}