{"record":{"id":"24345fb51827fd1d","repo":"JuliusBrussee/caveman","slug":"generic-record-d-w","errorCode":null,"errorMessage":"generic record %d: %w","messagePattern":"generic record (.+?): %w","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"shared/platform/importers/generic.go","lineNumber":75,"sourceCode":"func parseGeneric(data []byte, opts Options) ([]Span, error) {\n\tif err := validateGenericFieldMap(opts.FieldMap); err != nil {\n\t\treturn nil, err\n\t}\n\n\trecords, err := decodeGenericRecords(data)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tif len(records) == 0 {\n\t\treturn []Span{}, nil\n\t}\n\n\trows := make([]Span, 0, len(records))\n\tresolvedTargets := make(map[string]bool, len(opts.FieldMap))\n\tfor i, rec := range records {\n\t\tsp, resolved, err := mapGeneric(rec, opts)\n\t\tif err != nil {\n\t\t\treturn nil, fmt.Errorf(\"generic record %d: %w\", i+1, err)\n\t\t}\n\t\tfor target := range resolved {\n\t\t\tresolvedTargets[target] = true\n\t\t}\n\t\trows = append(rows, sp)\n\t}\n\tfor target, path := range opts.FieldMap {\n\t\tif !resolvedTargets[target] {\n\t\t\treturn nil, fmt.Errorf(\"mapped source path %q for target %q was not found in any record\", path, target)\n\t\t}\n\t}\n\treturn rows, nil\n}\n\nfunc validateGenericFieldMap(fieldMap map[string]string) error {\n\tif len(fieldMap) == 0 {\n\t\treturn fmt.Errorf(\"generic import requires a non-empty field map\")\n\t}","sourceCodeStart":57,"sourceCodeEnd":93,"githubUrl":"https://github.com/JuliusBrussee/caveman/blob/27d5a3981a347890211bb1bf2439e5c821a63bc9/shared/platform/importers/generic.go#L57-L93","documentation":"Thrown by the generic importer (shared/platform/importers/generic.go:75) when mapGeneric fails converting the i-th record (records are 1-based in the message) into a Span. The underlying cause is in the wrapped error: typically a source field mapped to a Span column has the wrong type or cannot be coerced. Like the JSONL importer, one bad record aborts the entire import.","triggerScenarios":"Calling the generic import with a FieldMap and a dataset where, in record N, a mapped path resolves to a value incompatible with its target column - e.g. timestamp mapped to a plain string 'yesterday', or span_id mapped to a number where a string is required. The wrapped error says which field and why.","commonSituations":"CSV/JSON exports where a column's type drifts between rows (empty cell parsed as null, numbers formatted with thousands separators); timestamps in a non-supported format; schema evolution in the source system adding new formats; trailing summary rows in reports.","solutions":["Read the wrapped error - it names the failing field and record; inspect that record directly.","Normalize the offending values at the source or in the FieldMap (map a different, consistently-typed source path).","Drop or quarantine rows that cannot conform (in your own pre-processing), then re-import.","For heterogeneous timestamps, pre-convert them to RFC3339 in the source file."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// dry-run the first record through the same mapping before the batch\nif len(records) > 0 {\n    if _, _, err := mapGenericRecord(records[0], opts); err != nil {\n        return fmt.Errorf(\"field map incompatible with sample record: %w\", err)\n    }\n}","typeGuard":null,"tryCatchPattern":"rows, err := importers.ImportGeneric(data, opts)\nif err != nil {\n    return fmt.Errorf(\"generic import failed at the record named in the error; nothing ingested: %w\", err)\n}","preventionTips":["Test the field map against a sample of real records before full imports.","Normalize timestamps to RFC3339 and IDs to strings in the source export.","Watch for type drift in CSV columns (empty cells, thousands separators)."],"tags":["go","import","data-validation","field-mapping"],"backgroundTag":null,"analyzedSha":"27d5a3981a347890211bb1bf2439e5c821a63bc9","analyzedAt":"2026-08-15T09:26:11.751Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}