{"record":{"id":"fae820ca74964cfa","repo":"JuliusBrussee/caveman","slug":"mapped-timestamp-is-missing-or-invalid","errorCode":null,"errorMessage":"mapped timestamp is missing or invalid","messagePattern":"mapped timestamp is missing or invalid","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"shared/platform/importers/generic.go","lineNumber":165,"sourceCode":"\t\tcase \"time\":\n\t\t\ts, ns := parseTimeFlexible(val)\n\t\t\tif target == \"timestamp\" {\n\t\t\t\tsp.Timestamp = s\n\t\t\t\tstartNs = ns\n\t\t\t} else {\n\t\t\t\tsp.EndTimestamp = s\n\t\t\t\tendNs = ns\n\t\t\t}\n\t\t}\n\t}\n\tif strings.TrimSpace(sp.TraceID) == \"\" {\n\t\treturn Span{}, nil, fmt.Errorf(\"mapped trace_id is empty\")\n\t}\n\tif strings.TrimSpace(sp.SpanID) == \"\" {\n\t\treturn Span{}, nil, fmt.Errorf(\"mapped span_id is empty\")\n\t}\n\tif sp.Timestamp == \"\" {\n\t\treturn Span{}, nil, fmt.Errorf(\"mapped timestamp is missing or invalid\")\n\t}\n\tif d := durationMS(startNs, endNs); d > 0 {\n\t\tsp.DurationMS = d\n\t}\n\tsp.Attributes = map[string]string{\"import.source\": \"generic\"}\n\tapplyScope(&sp, opts)\n\treturn sp, resolved, nil\n}\n\nfunc assignString(sp *Span, target, v string) {\n\tswitch target {\n\tcase \"trace_id\":\n\t\tsp.TraceID = v\n\tcase \"span_id\":\n\t\tsp.SpanID = v\n\tcase \"parent_span_id\":\n\t\tsp.ParentSpanID = v\n\tcase \"agent_slug\":","sourceCodeStart":147,"sourceCodeEnd":183,"githubUrl":"https://github.com/JuliusBrussee/caveman/blob/27d5a3981a347890211bb1bf2439e5c821a63bc9/shared/platform/importers/generic.go#L147-L183","documentation":"The mapped timestamp path resolved and parseTimeFlexible ran, but it could not produce a timestamp, leaving sp.Timestamp empty. parseTimeFlexible accepts several layouts (RFC3339 and common variants); a value outside all of them (unix epoch numbers aside) yields an empty string, which this guard rejects. Note the difference from 1182: the value existed but was unparseable.","triggerScenarios":"Timestamp formatted as e.g. \"01/02/2026 15:04\" or \"Jan 2, 2026\" which parseTimeFlexible does not accept; a locale-specific or custom-format string; the mapped value being a non-numeric string like \"n/a\"; value present but empty string.","commonSituations":"Excel/CSV-derived JSON with regional date formats; vendor changing timestamp format between export versions; mapping timestamp to a field that contains a display string rather than a machine timestamp.","solutions":["Convert timestamps to RFC3339 (e.g. 2026-01-02T15:04:05Z) in a pre-processing step before import","Confirm the mapped field holds a machine timestamp, not a localized display string","If you control the export, emit ISO-8601 with explicit timezone","Test one record through parseTimeFlexible-style layouts to find the accepted format"],"exampleFix":"// before\nrec := map[string]any{\"traceId\": \"t1\", \"spanId\": \"s1\", \"started_at\": \"02/01/2026 15:04\"}\n\n// after\nrec := map[string]any{\"traceId\": \"t1\", \"spanId\": \"s1\", \"started_at\": \"2026-01-02T15:04:00Z\"}","handlingStrategy":"validation","validationCode":"func timestampParses(v any) bool {\n\ts, ns := parseTimeFlexible(v)\n\treturn s != \"\" || ns != 0\n}","typeGuard":null,"tryCatchPattern":"if strings.Contains(err.Error(), \"timestamp is missing or invalid\") { /* normalize timestamps to RFC3339 and retry */ }","preventionTips":["Normalize all timestamps to RFC3339 with explicit timezone in pre-processing","Reject exports whose timestamp format deviates from ISO-8601 at ingest","Unit-test your normalizer against every format the source emits"],"tags":["go","import","generic","timestamp","parsing"],"backgroundTag":null,"analyzedSha":"27d5a3981a347890211bb1bf2439e5c821a63bc9","analyzedAt":"2026-08-15T09:26:11.751Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}