JuliusBrussee/caveman · error

generic target requires a non-empty source path

Error message

generic target %q requires a non-empty source path

What it means

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.

Solutions

  1. Set a real source path for the offending target (e.g. "service": "service_name").
  2. Remove the mapping entirely if you have no data for that column (unless it is a required target).
  3. Trace where the empty value comes from in your config/flag handling and guard against blank expansion.
  4. Trim and validate user-supplied paths before building the FieldMap.

Example fix

// before
fieldMap["service"] = os.Getenv("SRC_SERVICE_PATH") // empty env var
// after
if p := os.Getenv("SRC_SERVICE_PATH"); p != "" {
  fieldMap["service"] = p
}
Defensive patterns

Strategy: validation

Validate before calling

for target, path := range opts.FieldMap {
	if strings.TrimSpace(path) == "" {
		return fmt.Errorf("target %q has empty source path", target)
	}
}

Try / catch

rows, err := importers.ParseGeneric(data, opts)
if err != nil {
	if strings.Contains(err.Error(), "non-empty source path") {
		return fmt.Errorf("field map has a blank path value: %w", err)
	}
	return err
}

Prevention

When it happens

Trigger: Parse() with a FieldMap entry like {"service": ""} or {"service": " "}.

Common situations: 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.

Understand the failure class

Background: "Invalid value" and "allowed values are" config errors: what your library rejected and how to fix it — this error's family across 41 libraries.

Related errors


AI-assisted analysis of JuliusBrussee/caveman@3ee70a1026 (2026-09-20). Data as JSON: /api/errors/289b59f3677df886. Report an issue: GitHub.

Appendix: source

Thrown at shared/platform/importers/generic.go:99

	}
	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")
	}
	for target, path := range fieldMap {
		if _, ok := genericTargets[target]; !ok {
			return fmt.Errorf("unknown target column %q (not a caveman.spans column)", target)
		}
		if strings.TrimSpace(path) == "" {
			return fmt.Errorf("generic target %q requires a non-empty source path", target)
		}
	}
	for _, target := range []string{"trace_id", "span_id", "timestamp"} {
		if _, ok := fieldMap[target]; !ok {
			return fmt.Errorf("generic import requires a %q mapping", target)
		}
	}
	return nil
}

func decodeGenericRecords(data []byte) ([]map[string]any, error) {
	// Try a bare array first.
	var arr []map[string]any
	if err := json.Unmarshal(data, &arr); err == nil {
		return arr, nil
	}
	// Then a {"data":[...]} wrapper.
	var env struct {

View on GitHub (pinned to 3ee70a1026)