JuliusBrussee/caveman · error
generic record
Error message
generic record %d: %w
What it means
The generic importer maps source paths in each record to target Span columns via the user-supplied field map; mapGeneric failed for the record at the given 1-based index (missing path or uncoercible value), and parseGeneric wraps the per-record failure with the index.
Solutions
- Inspect record N (1-based) in the input and compare against your field map paths.
- Correct the field map paths or supply defaults for missing fields.
- Normalize the input first (fill nulls / drop partial rows) before importing.
- Dry-run the map against a sample record before the full import.
Defensive patterns
Strategy: validation
Validate before calling
for i, rec := range records {
for target, path := range opts.FieldMap {
if _, ok := lookupPath(rec, path); !ok {
log.Printf("record %d missing path %q for target %q", i+1, path, target)
}
}
} Try / catch
rows, err := importers.ParseGeneric(data, opts)
if err != nil {
if strings.HasPrefix(err.Error(), "generic record ") {
return fmt.Errorf("input row does not match field map: %w", err)
}
return err
} Prevention
- Dry-run the field map against the first record before a full import.
- Normalize records (fill missing keys with defaults) before mapping.
- Keep the field map and input schema versioned together.
- Reject input files whose keys diverge from a recorded sample schema.
When it happens
Trigger: Parse() on generic input where record N lacks a mapped source path, or the value at that path cannot be converted to the target column type.
Common situations: CSV/JSON rows with missing cells or inconsistent schemas; a field map written against a different schema version than the data; nested paths that only exist in some records.
Understand the failure class
Background: Schema validation failed / invalid input schema: payload rejected because its shape doesn't match the expected schema — this error's family across 28 libraries.
Related errors
- generic import requires a non-empty field map
- mapped source path for target was not found in any record
- generic import requires a
- generic target requires a non-empty source path
- unknown target column
AI-assisted analysis of JuliusBrussee/caveman@3ee70a1026 (2026-09-20).
Data as JSON: /api/errors/24345fb51827fd1d.
Report an issue: GitHub.
Appendix: source
Thrown at shared/platform/importers/generic.go:75
func parseGeneric(data []byte, opts Options) ([]Span, error) {
if err := validateGenericFieldMap(opts.FieldMap); err != nil {
return nil, err
}
records, err := decodeGenericRecords(data)
if err != nil {
return nil, err
}
if len(records) == 0 {
return []Span{}, nil
}
rows := make([]Span, 0, len(records))
resolvedTargets := make(map[string]bool, len(opts.FieldMap))
for i, rec := range records {
sp, resolved, err := mapGeneric(rec, opts)
if err != nil {
return nil, fmt.Errorf("generic record %d: %w", i+1, err)
}
for target := range resolved {
resolvedTargets[target] = true
}
rows = append(rows, sp)
}
for target, path := range opts.FieldMap {
if !resolvedTargets[target] {
return nil, fmt.Errorf("mapped source path %q for target %q was not found in any record", path, target)
}
}
return rows, nil
}
func validateGenericFieldMap(fieldMap map[string]string) error {
if len(fieldMap) == 0 {
return fmt.Errorf("generic import requires a non-empty field map")
}View on GitHub (pinned to 3ee70a1026)