JuliusBrussee/caveman · error
mapped timestamp is missing or invalid
Error message
mapped timestamp is missing or invalid
What it means
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.
Source
Thrown at shared/platform/importers/generic.go:165
case "time":
s, ns := parseTimeFlexible(val)
if target == "timestamp" {
sp.Timestamp = s
startNs = ns
} else {
sp.EndTimestamp = s
endNs = ns
}
}
}
if strings.TrimSpace(sp.TraceID) == "" {
return Span{}, nil, fmt.Errorf("mapped trace_id is empty")
}
if strings.TrimSpace(sp.SpanID) == "" {
return Span{}, nil, fmt.Errorf("mapped span_id is empty")
}
if sp.Timestamp == "" {
return Span{}, nil, fmt.Errorf("mapped timestamp is missing or invalid")
}
if d := durationMS(startNs, endNs); d > 0 {
sp.DurationMS = d
}
sp.Attributes = map[string]string{"import.source": "generic"}
applyScope(&sp, opts)
return sp, resolved, nil
}
func assignString(sp *Span, target, v string) {
switch target {
case "trace_id":
sp.TraceID = v
case "span_id":
sp.SpanID = v
case "parent_span_id":
sp.ParentSpanID = v
case "agent_slug":View on GitHub (pinned to 27d5a3981a)
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
Example fix
// before
rec := map[string]any{"traceId": "t1", "spanId": "s1", "started_at": "02/01/2026 15:04"}
// after
rec := map[string]any{"traceId": "t1", "spanId": "s1", "started_at": "2026-01-02T15:04:00Z"} Defensive patterns
Strategy: validation
Validate before calling
func timestampParses(v any) bool {
s, ns := parseTimeFlexible(v)
return s != "" || ns != 0
} Try / catch
if strings.Contains(err.Error(), "timestamp is missing or invalid") { /* normalize timestamps to RFC3339 and retry */ } Prevention
- 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
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- generic import requires a %q mapping
- generic decode: expected a JSON array or {"data":[...]} of o
- mapped source path %q for required target %q was not found
- mapped trace_id is empty
- mapped span_id is empty
AI-assisted analysis of JuliusBrussee/caveman@27d5a3981a (2026-08-15).
Data as JSON: /api/errors/fae820ca74964cfa.
Report an issue: GitHub.