SigNoz/signoz · warning

errors.CodeInvalidInput

errors.CodeInvalidInput

Error message

field `%s` not found

What it means

ColumnExpressionFor in the traces telemetry schema field mapper returns this invalid-input error when CandidateKeys returns no candidate column/metadata keys for the requested field — i.e., the field name is unknown to the trace schema under the current org and time range. The error carries Levenshtein suggestions built from the available keys map.

Source

Thrown at pkg/telemetryschema/tracestelemetryschema/field_mapper.go:432

) (string, error) {

	// Resolve the candidate logical field(s).
	var candidates []*telemetrytypes.LogicalField
	switch _, err := m.FieldFor(ctx, orgID, startNs, endNs, field); {
	case err == nil:
		// Every match from metadata is kept, similar to the filter path.
		candidates = querybuilder.MatchingLogicalFields(ctx, orgID, m.fl, field, keys)
		if len(candidates) == 0 {
			candidates = []*telemetrytypes.LogicalField{telemetrytypes.SingleLogicalField(field.Name, field)}
		}
	case errors.Is(err, qbtypes.ErrColumnNotFound):
		// The legacy candidate flow, unchanged: column (when the bare name is
		// one) plus metadata matches, else synthesized type-variant keys. The
		// family step below only swaps candidates for their family; it never
		// changes candidate order or non-family behavior.
		raw := m.CandidateKeys(ctx, orgID, field, nil, keys)
		if len(raw) == 0 {
			return "", errors.Wrapf(err, errors.TypeInvalidInput, errors.CodeInvalidInput, "field `%s` not found", field.Name).WithSuggestions(errors.NewSuggestionsOnLevenshteinDistance(field.Name, errors.NounKeys, maps.Keys(keys))...)
		}
		candidates = m.upgradeToFamilies(ctx, orgID, field, querybuilder.WrapAsLogicalFields(field.Name, raw), keys)
	default:
		return "", err
	}

	// Group-by/order (String) and aggregation (String/Float64): every candidate is
	// exists-guarded and coerced to requiredDataType, in a single multiIf. Raw select
	// (Unspecified) keeps the lighter native shape below.
	if requiredDataType != telemetrytypes.FieldDataTypeUnspecified {
		var dummyValue any = ""
		if requiredDataType == telemetrytypes.FieldDataTypeFloat64 {
			dummyValue = 0.0
		}
		stmts := make([]string, 0, len(candidates)*2)
		for _, logical := range candidates {
			value, err := querybuilder.LogicalValueExpr(ctx, orgID, startNs, endNs, m, logical)
			if err != nil {

View on GitHub (pinned to 5069bf80b0)

Solutions

  1. Check the error's suggestion list (WithSuggestions) for the closest known key and use it
  2. Verify the exact field name against the schema/keys map for the org and time range being queried
  3. Widen the time range or ensure the attribute has been ingested so metadata discovery registers the key
  4. If the field should be a known trace column, confirm the field context/type in the Field struct matches (a wrong FieldContext can eliminate all candidates)
  5. Surface suggestions to end users in the API response so typos are self-correcting

Example fix

// before
field := telemetrytypes.Field{Name: "servic.name"}

// after
field := telemetrytypes.Field{Name: "service.name"}
Defensive patterns

Strategy: validation

Validate before calling

// Pre-check candidates before mapping:
if len(mapper.CandidateKeys(ctx, orgID, field, nil, keys)) == 0 {
    return fmt.Errorf("field %q not found; try one of: %v", field.Name, maps.Keys(keys))
}

Type guard

func hasTraceCandidates(m Mapper, ctx context.Context, orgID string, f telemetrytypes.Field, keys map[string][]telemetrytypes.Field) bool {
    return len(m.CandidateKeys(ctx, orgID, f, nil, keys)) > 0
}

Try / catch

expr, err := mapper.ColumnExpressionFor(ctx, orgID, start, end, field)
if err != nil && errors.Ast(err, errors.TypeInvalidInput) {
    // return 400 with the Levenshtein suggestions attached to the error
}

Prevention

When it happens

Trigger: Calling ColumnExpressionFor (as the group-by builder in tests and query serving does) with a field name that is not a trace column and has no metadata entry: misspelled names, log/audit-only fields used against traces, or fields whose metadata keys were not yet discovered in the queried time window.

Common situations: Users typing attribute names from memory into a query builder, case or namespace mismatches (e.g. 'http.status_code' vs 'http_status_code'), or querying an org/time-range where the attribute has not appeared yet so metadata discovery has no key for it.

Related errors


AI-assisted analysis of SigNoz/signoz@5069bf80b0 (2026-08-28). Data as JSON: /api/errors/cab37f100fe54aa1. Report an issue: GitHub.