JuliusBrussee/caveman · error

unknown target column

Error message

unknown target column %q (not a caveman.spans column)

What it means

Error from validateGenericFieldMap: the field map for a generic import names a target column that is not one of the known caveman.spans columns. Import targets are a closed set; the offending target name is echoed so the map can be fixed.

Solutions

  1. Replace the unknown key with a valid caveman.spans column name (trace_id, span_id, timestamp, service, name, etc.).
  2. Check the genericTargets set in shared/platform/importers/generic.go for accepted columns.
  3. Use snake_case exactly — the lookup is exact-match.
  4. Mirror validateGenericFieldMap checks in your own tooling to catch this before Parse().

Example fix

// before
fieldMap := map[string]string{"id": "span_id_raw"}
// after
fieldMap := map[string]string{"span_id": "span_id_raw"}
Defensive patterns

Strategy: validation

Validate before calling

var genericTargets = map[string]bool{
	"trace_id": true, "span_id": true, "timestamp": true, // ...other caveman.spans columns
}
for target := range opts.FieldMap {
	if !genericTargets[target] {
		return fmt.Errorf("unknown target %q", target)
	}
}

Try / catch

rows, err := importers.ParseGeneric(data, opts)
if err != nil {
	if strings.Contains(err.Error(), "unknown target column") {
		return fmt.Errorf("check field map target names against caveman.spans schema: %w", err)
	}
	return err
}

Prevention

When it happens

Trigger: Parse() with a FieldMap containing a target like "start_time" or "id" that is not a caveman.spans column.

Common situations: Guessing column names instead of consulting the schema; mapping names from another tracing schema (OTel attribute names, Datadog columns); typos like "traceid" vs "trace_id".

Understand the failure class

Background: Invalid enum value errors: "Unknown type", "Invalid scope", "must be one of" — when a string is not on the library's allowed list — this error's family across 23 libraries.

Related errors


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

Appendix: source

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

			resolvedTargets[target] = true
		}
		rows = append(rows, sp)
	}
	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

View on GitHub (pinned to 3ee70a1026)