{"record":{"id":"c2eaf7c829016240","repo":"VictoriaMetrics/VictoriaMetrics","slug":"cannot-parse-timestamp-from-q-w","errorCode":null,"errorMessage":"cannot parse timestamp from %q: %w","messagePattern":"cannot parse timestamp from %q: %w","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"lib/protoparser/csvimport/parser.go","lineNumber":145,"sourceCode":"\t\tvar r Row\n\t\tcol := uint(0)\n\t\tmetrics = metrics[:0]\n\t\ttagsLen := len(tags)\n\t\tfor sc.NextColumn() {\n\t\t\tif col >= uint(len(cds)) {\n\t\t\t\t// Skip superfluous column.\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tcd := &cds[col]\n\t\t\tcol++\n\t\t\tif cd.isEmpty() || sc.Column == \"\" {\n\t\t\t\t// Ignore empty column.\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tif parseTimestamp := cd.ParseTimestamp; parseTimestamp != nil {\n\t\t\t\ttimestamp, err := parseTimestamp(sc.Column)\n\t\t\t\tif err != nil {\n\t\t\t\t\tsc.Error = fmt.Errorf(\"cannot parse timestamp from %q: %w\", sc.Column, err)\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t\tr.Timestamp = timestamp\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tif tagName := cd.TagName; tagName != \"\" {\n\t\t\t\ttags = append(tags, Tag{\n\t\t\t\t\tKey:   tagName,\n\t\t\t\t\tValue: sc.Column,\n\t\t\t\t})\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tmetricName := cd.MetricName\n\t\t\tif metricName == \"\" {\n\t\t\t\tlogger.Panicf(\"BUG: unexpected empty MetricName\")\n\t\t\t}\n\t\t\tvalue, err := fastfloat.Parse(sc.Column)\n\t\t\tif err != nil {","sourceCodeStart":127,"sourceCodeEnd":163,"githubUrl":"https://github.com/VictoriaMetrics/VictoriaMetrics/blob/5079fb58f1e8e62113f90c945ad71586c797d770/lib/protoparser/csvimport/parser.go#L127-L163","documentation":"parseRows (invoked from Unmarshal / UnmarshalDetectHeader) processes each CSV row against the parsed ColumnDescriptors. When the descriptor has a ParseTimestamp function and calling it on the row's time column fails, the row is marked with this error wrapping the underlying cause and the row is rejected.","triggerScenarios":"Calling csvimport.Unmarshal/UnmarshalDetectHeader on data whose time column cannot be parsed by the configured format — e.g. spec says time:unix_ms but rows contain RFC3339 strings; this error is the outer wrapper that surfaces errors 1013/1015/1016/1017/1018.","commonSituations":"Mixed-format timestamp columns across rows (some numeric, some formatted); empty timestamp cells; CSV data changed upstream (new exporter emits different format) while the spec stayed the same; rows with sentinel timestamps ('N/A', 0-filled).","solutions":["Read the wrapped cause in sc.Error (e.g. 'cannot parse time in RFC3339 from %q') to identify the exact failing cell and fix it or its format","Align the time entry format in ParseColumnDescriptors with the actual data format in the CSV","Pre-filter/normalize rows: drop or repair rows with empty or sentinel timestamps before calling Unmarshal","Dry-run parse the time column with the expected parser to find every bad row before import"],"exampleFix":"// before: data is RFC3339 but spec is unix_ms\ncds, _ := csvimport.ParseColumnDescriptors(\"time:unix_ms,metric\")\nrows, err := csvimport.Unmarshal(data, cds) // fails\n// after\ncds, _ := csvimport.ParseColumnDescriptors(\"time:rfc3339,metric\")\nrows, err := csvimport.Unmarshal(data, cds)","handlingStrategy":"try-catch","validationCode":"func dryRunTimestamps(data []byte, cds []csvimport.ColumnDescriptor) error {\n\tfor i, row := range strings.Split(string(data), \"\\n\") {\n\t\tcols := strings.Split(row, \",\")\n\t\tfor _, cd := range cds {\n\t\t\tif cd.ParseTimestamp != nil {\n\t\t\t\tidx := int(cd.ColumnPos()) - 1 // adapt to your descriptor API\n\t\t\t\tif idx >= 0 && idx < len(cols) {\n\t\t\t\t\tif _, err := cd.ParseTimestamp(cols[idx]); err != nil {\n\t\t\t\t\t\treturn fmt.Errorf(\"row %d: %w\", i+1, err)\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\treturn nil\n}","typeGuard":null,"tryCatchPattern":"rows, err := csvimport.Unmarshal(data, cds)\nif err != nil {\n\tvar scErr string\n\tif strings.Contains(err.Error(), \"cannot parse timestamp from\") {\n\t\t// log the row, quarantine it, and continue with valid rows instead of aborting\n\t\t_ = scErr\n\t}\n}","preventionTips":["Always run a small sample through Unmarshal before processing the full file","Keep the time format in ParseColumnDescriptors in sync with the upstream exporter; version them together","Drop or fix empty/sentinel timestamp cells in preprocessing","Treat this error as a row-level data problem: extract the wrapped cause from the message to locate the cell"],"tags":["csvimport","timestamp","row-parsing","data-quality"],"backgroundTag":"timestamp-parse-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"}