{"record":{"id":"f33a21c26be37d2d","repo":"JuliusBrussee/caveman","slug":"mapped-source-path-q-for-target-q-was-not-found","errorCode":null,"errorMessage":"mapped source path %q for target %q was not found in any record","messagePattern":"mapped source path %q for target %q was not found in any record","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"shared/platform/importers/generic.go","lineNumber":84,"sourceCode":"\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}\n\tfor target, path := range fieldMap {\n\t\tif _, ok := genericTargets[target]; !ok {\n\t\t\treturn fmt.Errorf(\"unknown target column %q (not a caveman.spans column)\", target)\n\t\t}\n\t\tif strings.TrimSpace(path) == \"\" {\n\t\t\treturn fmt.Errorf(\"generic target %q requires a non-empty source path\", target)\n\t\t}\n\t}\n\tfor _, target := range []string{\"trace_id\", \"span_id\", \"timestamp\"} {","sourceCodeStart":66,"sourceCodeEnd":102,"githubUrl":"https://github.com/JuliusBrussee/caveman/blob/27d5a3981a347890211bb1bf2439e5c821a63bc9/shared/platform/importers/generic.go#L66-L102","documentation":"Thrown by the generic importer (generic.go:84) after all records were converted: some target in the FieldMap was never resolved by any record's mapped source path. The design refuses a mapping that silently produces empty columns - every declared target must be found at least once, or the whole import fails. The message names both the source path and the target.","triggerScenarios":"FieldMap maps target 'trace_id' to path 'ctx.trace' but no record in the dataset contains that path (typo in the path, renamed key in the source, or case mismatch), so resolvedTargets never gains 'trace_id' and the post-loop check fires.","commonSituations":"Field map written against documentation that drifted from the actual export; nested-path syntax wrong (e.g. 'traceId' vs 'trace_id', or missing a nesting level); source switched from flat to nested JSON; a sample-based map applied to a differently-shaped full export.","solutions":["Check the exact path in the error against a real record: jq '.[0]' or head -1 of the source.","Fix the path spelling/nesting/case in the FieldMap to match the data.","If the target is genuinely absent from the source, remove it from the FieldMap - optional columns must not be declared.","Re-run; the check passes only when every mapped path resolves in at least one record."],"exampleFix":"# before\nfieldMap = {\"trace_id\": \"ctx.traceID\", ...}   # data uses ctx.trace_id\n\n# after\nfieldMap = {\"trace_id\": \"ctx.trace_id\", ...}","handlingStrategy":"validation","validationCode":"// every mapped path must resolve in at least one sample record\nresolved := map[string]bool{}\nfor _, rec := range sample {\n    for target, path := range fieldMap {\n        if _, ok := lookupPath(rec, path); ok { resolved[target] = true }\n    }\n}\nfor target, path := range fieldMap {\n    if !resolved[target] { return fmt.Errorf(\"path %q never resolves; fix field map\", path) }\n}","typeGuard":null,"tryCatchPattern":"if _, err := importers.ImportGeneric(data, opts); err != nil {\n    return err // path/target in the message tells you which mapping is stale\n}","preventionTips":["Derive field maps from a real record (jq keys) rather than from docs.","Re-validate the map whenever the source schema changes.","Include the source export's schema version alongside the field map."],"tags":["go","import","field-mapping","config"],"backgroundTag":null,"analyzedSha":"27d5a3981a347890211bb1bf2439e5c821a63bc9","analyzedAt":"2026-08-15T09:26:11.751Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}