{"record":{"id":"762db347995317e4","repo":"VictoriaMetrics/VictoriaMetrics","slug":"cannot-find-whitespace-between-metric-and-timestam","errorCode":null,"errorMessage":"cannot find whitespace between metric and timestamp in %q","messagePattern":"cannot find whitespace between metric and timestamp in %q","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"lib/protoparser/opentsdb/parser.go","lineNumber":68,"sourceCode":"\nfunc (r *Row) reset() {\n\tr.Metric = \"\"\n\tr.Tags = nil\n\tr.Value = 0\n\tr.Timestamp = 0\n}\n\nfunc (r *Row) unmarshal(s string, tagsPool []Tag) ([]Tag, error) {\n\tr.reset()\n\ts = trimLeadingSpaces(s)\n\tif !strings.HasPrefix(s, \"put \") {\n\t\treturn tagsPool, fmt.Errorf(\"missing `put ` prefix in %q\", s)\n\t}\n\ts = s[len(\"put \"):]\n\ts = trimLeadingSpaces(s)\n\tn := strings.IndexByte(s, ' ')\n\tif n < 0 {\n\t\treturn tagsPool, fmt.Errorf(\"cannot find whitespace between metric and timestamp in %q\", s)\n\t}\n\tr.Metric = s[:n]\n\tif len(r.Metric) == 0 {\n\t\treturn tagsPool, fmt.Errorf(\"metric cannot be empty\")\n\t}\n\ttail := trimLeadingSpaces(s[n+1:])\n\tn = strings.IndexByte(tail, ' ')\n\tif n < 0 {\n\t\treturn tagsPool, fmt.Errorf(\"cannot find whitespace between timestamp and value in %q\", s)\n\t}\n\ttimestamp, err := fastfloat.Parse(tail[:n])\n\tif err != nil {\n\t\treturn tagsPool, fmt.Errorf(\"cannot parse timestamp from %q: %w\", tail[:n], err)\n\t}\n\tr.Timestamp = int64(timestamp)\n\ttail = trimLeadingSpaces(tail[n+1:])\n\tvalueStr := \"\"\n\ttagsStr := \"\"","sourceCodeStart":50,"sourceCodeEnd":86,"githubUrl":"https://github.com/VictoriaMetrics/VictoriaMetrics/blob/5079fb58f1e8e62113f90c945ad71586c797d770/lib/protoparser/opentsdb/parser.go#L50-L86","documentation":"After stripping the 'put ' prefix, Row.unmarshal expects a whitespace separating the metric name from the timestamp. If no space is found, this error is returned with the offending string. The line is structurally invalid for the OpenTSDB put protocol.","triggerScenarios":"Sending a put line like 'put mymetric\\t...' with a non-space separator that survives trimming, or 'put mymetric' with no fields at all.","commonSituations":"Using tabs or multiple-space formatting that leaves IndexByte(' ') failing after trimming; truncated lines from broken scripts or cut-and-paste; locale-related separators.","solutions":["Format each line as 'put <metric> <timestamp> <value> <tags>' with plain ASCII spaces.","Check for tab-separated output from the producing script and convert to spaces.","Log/print the offending line (shown in the error) and fix its formatting.","Validate lines with a regex before sending: ^put \\S+ \\d+ \\S+.*$."],"exampleFix":"// before\nfmt.Printf(\"put %s\\t%d\\t%v\\n\", metric, ts, val)\n// after\nfmt.Printf(\"put %s %d %v\\n\", metric, ts, val)","handlingStrategy":"validation","validationCode":"// ensure space-separated fields before sending\nfields := strings.Fields(line)\nif len(fields) < 4 {\n    return fmt.Errorf(\"opentsdb line needs >=4 fields: %q\", line)\n}","typeGuard":null,"tryCatchPattern":"if err := parser.Parse(body, cb); err != nil {\n    if strings.Contains(err.Error(), \"cannot find whitespace between metric and timestamp\") {\n        // offending line is quoted in the error\n    }\n}","preventionTips":["Use single ASCII spaces between all fields","Convert tab-separated output to spaces","Validate with strings.Fields count == expected"],"tags":["opentsdb","line-protocol","formatting"],"backgroundTag":"malformed-tsdb-line","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"}