JuliusBrussee/caveman · error
mapped trace_id is empty
Error message
mapped trace_id is empty
What it means
After mapping, the generic importer checks that the resolved trace_id is non-empty (after trimming whitespace). This error means the mapped path resolved to a value, but the resulting string is empty or whitespace — the record effectively has no trace identity. It is fail-closed so blank-key spans are never ingested.
Solutions
- Inspect records for empty/null values at the mapped trace_id path and remove or repair them
- Filter out records with blank trace IDs before calling Parse
- Fix the upstream exporter so trace IDs are always populated
- If trace_id lives under a different key for empty cases, remap FieldMap to the correct path
Example fix
// before: record with null trace id
{"trace":{"id":null},"id":"span-1",...}
// after: filter before import or repair the value
{"trace":{"id":"abc123"},"id":"span-1",...} Defensive patterns
Strategy: validation
Validate before calling
func hasNonEmptyString(rec map[string]any, path string) bool {
v, ok := lookupPath(rec, path)
if !ok { return false }
s, ok := v.(string)
return ok && strings.TrimSpace(s) != ""
}
// guard: if !hasNonEmptyString(rec, fieldMap["trace_id"]) { skip/log record } Type guard
func nonEmptyString(v any) bool { s, ok := v.(string); return ok && strings.TrimSpace(s) != "" } Try / catch
rows, err := importers.Parse(data, opts)
if err != nil {
if strings.Contains(err.Error(), "mapped trace_id is empty") {
return fmt.Errorf("drop/repair records with blank trace_id before import: %w", err)
}
return err
} Prevention
- Filter blank/null trace IDs out before calling Parse
- Audit upstream exports for empty identity fields
- Treat null and "" at mapped paths as missing during pre-validation
- Repair orphaned spans at the exporter rather than the importer
When it happens
Trigger: A record contains the mapped trace_id key but with value "", " ", or null, so lookupPath succeeds but asString yields an empty string.
Common situations: Upstream export wrote empty trace IDs for orphaned spans; a CSV-to-JSON converter emitted "" instead of omitting the field; JSON null at the mapped path; data migration left placeholder blanks.
Understand the failure class
Background: "must not be empty", "cannot be empty" — required-field validation errors across open-source libraries — this error's family across 41 libraries.
Related errors
- mapped source path for required target was not found
- mapped span_id is empty
- generic decode: expected a JSON array or
- mapped timestamp is missing or invalid
- apiKey, baseURL, and agent are required
AI-assisted analysis of JuliusBrussee/caveman@3ee70a1026 (2026-09-20).
Data as JSON: /api/errors/1e991645c95678cd.
Report an issue: GitHub.
Appendix: source
Thrown at shared/platform/importers/generic.go:159
case "string":
assignString(&sp, target, asString(val))
case "int":
assignInt(&sp, target, parseFlexInt(val))
case "float":
sp.TotalCostUSD = roundUSD(parseFlexFloat(val))
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":View on GitHub (pinned to 3ee70a1026)