{"record":{"id":"289b59f3677df886","repo":"JuliusBrussee/caveman","slug":"generic-target-q-requires-a-non-empty-source-path","errorCode":null,"errorMessage":"generic target %q requires a non-empty source path","messagePattern":"generic target %q requires a non-empty source path","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"shared/platform/importers/generic.go","lineNumber":99,"sourceCode":"\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\"} {\n\t\tif _, ok := fieldMap[target]; !ok {\n\t\t\treturn fmt.Errorf(\"generic import requires a %q mapping\", target)\n\t\t}\n\t}\n\treturn nil\n}\n\nfunc decodeGenericRecords(data []byte) ([]map[string]any, error) {\n\t// Try a bare array first.\n\tvar arr []map[string]any\n\tif err := json.Unmarshal(data, &arr); err == nil {\n\t\treturn arr, nil\n\t}\n\t// Then a {\"data\":[...]} wrapper.\n\tvar env struct {","sourceCodeStart":81,"sourceCodeEnd":117,"githubUrl":"https://github.com/JuliusBrussee/caveman/blob/3ee70a102609e550bd2e68004bf5990a9341c851/shared/platform/importers/generic.go#L81-L117","documentation":"Error from validateGenericFieldMap: a field-map entry maps a known target column to an empty or whitespace-only source path. Every target needs a non-empty JSON path into the source records; the message names the requirement directly.","triggerScenarios":"Parse() with a FieldMap entry like {\"service\": \"\"} or {\"service\": \"   \"}.","commonSituations":"Templated config where a variable failed to expand and resolved to empty; hand-edited config leaving a blank path; programmatic construction inserting empty strings for optional targets.","solutions":["Set a real source path for the offending target (e.g. \"service\": \"service_name\").","Remove the mapping entirely if you have no data for that column (unless it is a required target).","Trace where the empty value comes from in your config/flag handling and guard against blank expansion.","Trim and validate user-supplied paths before building the FieldMap."],"exampleFix":"// before\nfieldMap[\"service\"] = os.Getenv(\"SRC_SERVICE_PATH\") // empty env var\n// after\nif p := os.Getenv(\"SRC_SERVICE_PATH\"); p != \"\" {\n  fieldMap[\"service\"] = p\n}","handlingStrategy":"validation","validationCode":"for target, path := range opts.FieldMap {\n\tif strings.TrimSpace(path) == \"\" {\n\t\treturn fmt.Errorf(\"target %q has empty source path\", target)\n\t}\n}","typeGuard":null,"tryCatchPattern":"rows, err := importers.ParseGeneric(data, opts)\nif err != nil {\n\tif strings.Contains(err.Error(), \"non-empty source path\") {\n\t\treturn fmt.Errorf(\"field map has a blank path value: %w\", err)\n\t}\n\treturn err\n}","preventionTips":["Trim and check every path when constructing the FieldMap.","Guard templated configs against unexpanded/empty variables.","Skip optional targets rather than inserting empty-string paths."],"tags":["generic-import","field-map","config","validation"],"backgroundTag":"invalid-config-value","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"}