{"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/3ee70a102609e550bd2e68004bf5990a9341c851/shared/platform/importers/generic.go#L57-L93","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"for i, rec := range records {\n\tfor target, path := range opts.FieldMap {\n\t\tif _, ok := lookupPath(rec, path); !ok {\n\t\t\tlog.Printf(\"record %d missing path %q for target %q\", i+1, path, target)\n\t\t}\n\t}\n}","typeGuard":null,"tryCatchPattern":"rows, err := importers.ParseGeneric(data, opts)\nif err != nil {\n\tif strings.HasPrefix(err.Error(), \"generic record \") {\n\t\treturn fmt.Errorf(\"input row does not match field map: %w\", err)\n\t}\n\treturn err\n}","preventionTips":["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."],"tags":["generic-import","field-map","importer","data-mapping"],"backgroundTag":"schema-validation-failed","analyzedSha":"3ee70a102609e550bd2e68004bf5990a9341c851","analyzedAt":"2026-09-20T15:53:39.229Z","contentChangedAt":"2026-09-20T15:53:39.229Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}