{"record":{"id":"57b6b5d370d3c872","repo":"SigNoz/signoz","slug":"invalid-scope-item-type-s","errorCode":null,"errorMessage":"invalid scope item type: %s","messagePattern":"invalid scope item type: (.+?)","errorType":"validation","errorClass":null,"httpStatus":400,"severity":"error","filePath":"pkg/query-service/app/traces/v4/query_builder.go","lineNumber":253,"sourceCode":"\tvar query string\n\tif fs == nil || len(fs.Items) == 0 {\n\t\treturn \"\", nil\n\t}\n\tfor _, item := range fs.Items {\n\t\t// skip anything other than Span Search scope attribute\n\t\tif item.Key.Type != v3.AttributeKeyTypeSpanSearchScope {\n\t\t\tcontinue\n\t\t}\n\t\tkeyName := strings.ToLower(item.Key.Key)\n\n\t\tif keyName == constants.SpanSearchScopeRoot {\n\t\t\tquery = \"parent_span_id = '' \"\n\t\t\treturn query, nil\n\t\t} else if keyName == constants.SpanSearchScopeEntryPoint {\n\t\t\tquery = \"((name, `resource_string_service$$name`) GLOBAL IN ( SELECT DISTINCT name, serviceName from \" + constants.SIGNOZ_TRACE_DBNAME + \".\" + constants.SIGNOZ_TOP_LEVEL_OPERATIONS_TABLENAME + \" )) AND parent_span_id != '' \"\n\t\t\treturn query, nil\n\t\t} else {\n\t\t\treturn \"\", fmt.Errorf(\"invalid scope item type: %s\", item.Key.Type)\n\t\t}\n\t}\n\treturn \"\", nil\n}\n\nfunc buildTracesQuery(start, end, step int64, mq *v3.BuilderQuery, panelType v3.PanelType, options v3.QBOptions) (string, error) {\n\ttracesStart := utils.GetEpochNanoSecs(start)\n\ttracesEnd := utils.GetEpochNanoSecs(end)\n\n\t// -1800 this is added so that the bucket start considers all the fingerprints.\n\tbucketStart := tracesStart/NANOSECOND - 1800\n\tbucketEnd := tracesEnd / NANOSECOND\n\n\ttimeFilter := fmt.Sprintf(\"(timestamp >= '%d' AND timestamp <= '%d') AND (ts_bucket_start >= %d AND ts_bucket_start <= %d)\", tracesStart, tracesEnd, bucketStart, bucketEnd)\n\n\tfilterSubQuery, err := BuildTracesFilterQuery(mq.Filters, true)\n\tif err != nil {\n\t\treturn \"\", err","sourceCodeStart":235,"sourceCodeEnd":271,"githubUrl":"https://github.com/SigNoz/signoz/blob/5069bf80b08f1f00d7e014eccc09902f9871004f/pkg/query-service/app/traces/v4/query_builder.go#L235-L271","documentation":"buildSpanScopeQuery handles special span search scope keys (parent/entrypoint). If the filter item's key type is something other than the recognized scope types, the key name falls through to the error branch. Effectively an unrecognized span-scope filter key/type combination.","triggerScenarios":"Sending a filter where item.Key.Type designates a scope search but keyName is not the recognized parent or entrypoint scope constant (e.g. a misspelled scope name or a new scope type).","commonSituations":"Custom clients constructing span-scope filters by hand; frontend changes introducing new scope names before query-service supports them; version skew between UI and backend constants.","solutions":["Use the exact constants (constants.SpanSearchScopeEntryPoint etc.) defined in the siglens/signoz constants package for scope keys","Upgrade query-service so its scope constants match the client","Remove the invalid scope filter"],"exampleFix":"// before\n{\"key\":{\"key\":\"entry_point\",\"type\":\"scope\"}}\n\n// after\n{\"key\":{\"key\":\"entrypoint\",\"type\":\"scope\"}} // matches constants.SpanSearchScopeEntryPoint","handlingStrategy":"validation","validationCode":"const validScopes = map[string]bool{constants.SpanSearchScopeEntryPoint: true /* , parent */}\nif item.Key.Type == v3.AttributeKeyTypeScope && !validScopes[item.Key.Key] {\n    return fmt.Errorf(\"unknown scope key %s\", item.Key.Key)\n}","typeGuard":"func isValidScopeKey(name string) bool {\n    return name == constants.SpanSearchScopeEntryPoint || name == constants.SpanSearchScopeParent\n}","tryCatchPattern":null,"preventionTips":["Import scope constants from the same package version as the server","Add integration tests for scope filters"],"tags":["signoz","traces","v4","scope","validation"],"backgroundTag":"query-validation-failed","analyzedSha":"5069bf80b08f1f00d7e014eccc09902f9871004f","analyzedAt":"2026-08-28T06:22:12.824Z","schemaVersion":2},"datasetVersion":"2026-08-28T11:17:15.048Z"}