{"record":{"id":"cab37f100fe54aa1","repo":"SigNoz/signoz","slug":"errors-codeinvalidinput-cab37f","errorCode":"errors.CodeInvalidInput","errorMessage":"field `%s` not found","messagePattern":"field `(.+?)` not found","errorType":"validation","errorClass":null,"httpStatus":400,"severity":"warning","filePath":"pkg/telemetryschema/tracestelemetryschema/field_mapper.go","lineNumber":432,"sourceCode":") (string, error) {\n\n\t// Resolve the candidate logical field(s).\n\tvar candidates []*telemetrytypes.LogicalField\n\tswitch _, err := m.FieldFor(ctx, orgID, startNs, endNs, field); {\n\tcase err == nil:\n\t\t// Every match from metadata is kept, similar to the filter path.\n\t\tcandidates = querybuilder.MatchingLogicalFields(ctx, orgID, m.fl, field, keys)\n\t\tif len(candidates) == 0 {\n\t\t\tcandidates = []*telemetrytypes.LogicalField{telemetrytypes.SingleLogicalField(field.Name, field)}\n\t\t}\n\tcase errors.Is(err, qbtypes.ErrColumnNotFound):\n\t\t// The legacy candidate flow, unchanged: column (when the bare name is\n\t\t// one) plus metadata matches, else synthesized type-variant keys. The\n\t\t// family step below only swaps candidates for their family; it never\n\t\t// changes candidate order or non-family behavior.\n\t\traw := m.CandidateKeys(ctx, orgID, field, nil, keys)\n\t\tif len(raw) == 0 {\n\t\t\treturn \"\", errors.Wrapf(err, errors.TypeInvalidInput, errors.CodeInvalidInput, \"field `%s` not found\", field.Name).WithSuggestions(errors.NewSuggestionsOnLevenshteinDistance(field.Name, errors.NounKeys, maps.Keys(keys))...)\n\t\t}\n\t\tcandidates = m.upgradeToFamilies(ctx, orgID, field, querybuilder.WrapAsLogicalFields(field.Name, raw), keys)\n\tdefault:\n\t\treturn \"\", err\n\t}\n\n\t// Group-by/order (String) and aggregation (String/Float64): every candidate is\n\t// exists-guarded and coerced to requiredDataType, in a single multiIf. Raw select\n\t// (Unspecified) keeps the lighter native shape below.\n\tif requiredDataType != telemetrytypes.FieldDataTypeUnspecified {\n\t\tvar dummyValue any = \"\"\n\t\tif requiredDataType == telemetrytypes.FieldDataTypeFloat64 {\n\t\t\tdummyValue = 0.0\n\t\t}\n\t\tstmts := make([]string, 0, len(candidates)*2)\n\t\tfor _, logical := range candidates {\n\t\t\tvalue, err := querybuilder.LogicalValueExpr(ctx, orgID, startNs, endNs, m, logical)\n\t\t\tif err != nil {","sourceCodeStart":414,"sourceCodeEnd":450,"githubUrl":"https://github.com/SigNoz/signoz/blob/5069bf80b08f1f00d7e014eccc09902f9871004f/pkg/telemetryschema/tracestelemetryschema/field_mapper.go#L414-L450","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Check the error's suggestion list (WithSuggestions) for the closest known key and use it","Verify the exact field name against the schema/keys map for the org and time range being queried","Widen the time range or ensure the attribute has been ingested so metadata discovery registers the key","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)","Surface suggestions to end users in the API response so typos are self-correcting"],"exampleFix":"// before\nfield := telemetrytypes.Field{Name: \"servic.name\"}\n\n// after\nfield := telemetrytypes.Field{Name: \"service.name\"}","handlingStrategy":"validation","validationCode":"// Pre-check candidates before mapping:\nif len(mapper.CandidateKeys(ctx, orgID, field, nil, keys)) == 0 {\n    return fmt.Errorf(\"field %q not found; try one of: %v\", field.Name, maps.Keys(keys))\n}","typeGuard":"func hasTraceCandidates(m Mapper, ctx context.Context, orgID string, f telemetrytypes.Field, keys map[string][]telemetrytypes.Field) bool {\n    return len(m.CandidateKeys(ctx, orgID, f, nil, keys)) > 0\n}","tryCatchPattern":"expr, err := mapper.ColumnExpressionFor(ctx, orgID, start, end, field)\nif err != nil && errors.Ast(err, errors.TypeInvalidInput) {\n    // return 400 with the Levenshtein suggestions attached to the error\n}","preventionTips":["Validate group-by/filter fields against the org's discovered schema before executing queries","Ensure metadata discovery covers the queried time range before serving user queries","Test with the same FieldContext and field type users will send; mismatches silently yield zero candidates"],"tags":["field-mapping","unknown-field","traces","typo","suggestions","go"],"backgroundTag":"unknown-field-name-in-query","analyzedSha":"5069bf80b08f1f00d7e014eccc09902f9871004f","analyzedAt":"2026-08-28T06:22:12.824Z","schemaVersion":2},"datasetVersion":"2026-08-28T11:17:15.048Z"}