{"record":{"id":"e70d1d69dee2613a","repo":"VictoriaMetrics/VictoriaMetrics","slug":"cannot-read-timestamp-e70d1d","errorCode":null,"errorMessage":"cannot read timestamp","messagePattern":"cannot read timestamp","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"lib/protoparser/datadogsketches/parser.go","lineNumber":270,"sourceCode":"\td.Ts = 0\n\td.Cnt = 0\n\td.Min = 0.0\n\td.Max = 0.0\n\td.Sum = 0.0\n\td.K = nil\n\td.N = nil\n\n\tvar fc easyproto.FieldContext\n\tfor len(src) > 0 {\n\t\tsrc, err = fc.NextField(src)\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"cannot read next field in Dogsketch message: %w\", err)\n\t\t}\n\t\tswitch fc.FieldNum {\n\t\tcase 1:\n\t\t\tts, ok := fc.Int64()\n\t\t\tif !ok {\n\t\t\t\treturn fmt.Errorf(\"cannot read timestamp\")\n\t\t\t}\n\t\t\td.Ts = ts\n\t\tcase 2:\n\t\t\tcnt, ok := fc.Int64()\n\t\t\tif !ok {\n\t\t\t\treturn fmt.Errorf(\"cannot read count\")\n\t\t\t}\n\t\t\td.Cnt = cnt\n\t\tcase 3:\n\t\t\tv, ok := fc.Double()\n\t\t\tif !ok {\n\t\t\t\treturn fmt.Errorf(\"cannot read min\")\n\t\t\t}\n\t\t\td.Min = v\n\t\tcase 4:\n\t\t\tv, ok := fc.Double()\n\t\t\tif !ok {\n\t\t\t\treturn fmt.Errorf(\"cannot read max\")","sourceCodeStart":252,"sourceCodeEnd":288,"githubUrl":"https://github.com/VictoriaMetrics/VictoriaMetrics/blob/5079fb58f1e8e62113f90c945ad71586c797d770/lib/protoparser/datadogsketches/parser.go#L252-L288","documentation":"Thrown by Dogsketch.unmarshalProtobuf when field 1 (ts, int64 timestamp) cannot be read as a varint — easyproto's fc.Int64() returned false because the wire type is not varint (0). The failure aborts the Dogsketch and surfaces wrapped as 'cannot unmarshal Dogsketch: cannot read timestamp'.","triggerScenarios":"Dogsketch field 1 is encoded as length-delimited or fixed64 instead of varint, or earlier-field misalignment causes a non-varint value to be read as field 1.","commonSituations":"Custom serializer writing ts as a fixed-size or string field; proto field renumbering in a forked schema; corrupted bytes making the tag point at the wrong value.","solutions":["Fix the producer so `int64 ts = 1` is encoded as a varint (wire type 0).","Verify field 1's wire type with protoc --decode_raw on the failing Dogsketch.","Pin matching agent-payload proto versions across producer and consumer.","Add round-trip serialization tests (marshal then unmarshal a known Dogsketch) to the producer's CI."],"exampleFix":"// before (bad producer code)\nbuf = appendFixed64(buf, 1, uint64(ts))\n// after\nbuf = appendVarintField(buf, 1, uint64(ts)) // wire type 0","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"if err := sp.UnmarshalProtobuf(buf); err != nil {\n    if strings.Contains(err.Error(), \"cannot read timestamp\") {\n        metrics.Inc(\"dogsketch_bad_timestamp_field\")\n        http.Error(w, \"malformed dogsketch\", http.StatusBadRequest)\n        return\n    }\n    return err\n}","preventionTips":["Encode ts (field 1) as varint int64 (wire type 0)","Round-trip test Dogsketch serialization in the producer's CI","Keep proto field numbers stable across versions","Validate payloads from third-party senders before parsing"],"tags":["protobuf","wire-type","datadog","varint"],"backgroundTag":"protobuf-wire-type-mismatch","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"}