{"record":{"id":"fe26623a9aac7822","repo":"SigNoz/signoz","slug":"invalid-data-type-for-resource-attribute-s","errorCode":null,"errorMessage":"invalid data type for resource attribute: %s","messagePattern":"invalid data type for resource attribute: (.+?)","errorType":"validation","errorClass":null,"httpStatus":400,"severity":"error","filePath":"pkg/query-service/app/resource/resource_query_builder.go","lineNumber":228,"sourceCode":"\tif fs == nil || len(fs.Items) == 0 {\n\t\treturn nil, nil\n\t}\n\tfor _, item := range fs.Items {\n\t\t// skip anything other than resource attribute\n\t\tif item.Key.Type != v3.AttributeKeyTypeResource {\n\t\t\tcontinue\n\t\t}\n\n\t\t// since out map is in lower case we are converting it to lowercase\n\t\toperatorLower := strings.ToLower(string(item.Operator))\n\t\top := v3.FilterOperator(operatorLower)\n\t\tkeyName := item.Key.Key\n\n\t\t// resource filter value data type will always be string\n\t\t// will be an interface if the operator is IN or NOT IN\n\t\tif item.Key.DataType != v3.AttributeKeyDataTypeString &&\n\t\t\t(op != v3.FilterOperatorIn && op != v3.FilterOperatorNotIn) {\n\t\t\treturn nil, fmt.Errorf(\"invalid data type for resource attribute: %s\", item.Key.Key)\n\t\t}\n\n\t\tvar value interface{}\n\t\tvar err error\n\t\tif op != v3.FilterOperatorExists && op != v3.FilterOperatorNotExists {\n\t\t\t// make sure to cast the value regardless of the actual type\n\t\t\tvalue, err = utils.ValidateAndCastValue(item.Value, item.Key.DataType)\n\t\t\tif err != nil {\n\t\t\t\treturn nil, fmt.Errorf(\"failed to validate and cast value for %s: %v\", item.Key.Key, err)\n\t\t\t}\n\t\t}\n\n\t\tif logsOp, ok := resourceLogOperators[op]; ok {\n\t\t\tmembers := []string{keyName}\n\t\t\tif resolveSemconvFamilies {\n\t\t\t\tmembers = semconv.Members(semconv.KindAttribute, telemetrytypes.FieldKeySelector{\n\t\t\t\t\tName:         keyName,\n\t\t\t\t\tSignal:       telemetrytypes.SignalTraces,","sourceCodeStart":210,"sourceCodeEnd":246,"githubUrl":"https://github.com/SigNoz/signoz/blob/5069bf80b08f1f00d7e014eccc09902f9871004f/pkg/query-service/app/resource/resource_query_builder.go#L210-L246","documentation":"buildResourceFiltersFromFilterItems rejects a resource filter whose key DataType is not string unless the operator is IN or NOT_IN. Resource attribute filter values are expected to be strings (or lists for IN/NOT IN), so numeric/bool typed keys fail this validation.","triggerScenarios":"Applying a resource filter on a log query where the attribute key has DataType like float64/int64/bool and the operator is =, !=, contains, etc. (not in/not nin).","commonSituations":"Selecting a numerically-typed resource attribute in the logs explorer filter bar with an equality operator; programmatic filter sets built from saved views that stored a non-string data type for the key.","solutions":["Use the in (IN) or not in (NOT IN) operator if you must filter a non-string resource attribute","Change the key's DataType to string in the filter item before sending","Filter on the corresponding body/severity field instead if it is not a resource attribute"],"exampleFix":"// before\nitem.Key.DataType = v3.AttributeKeyDataTypeFloat64\nitem.Operator = v3.FilterOperatorEqual\n\n// after\nitem.Operator = v3.FilterOperatorIn // IN/NOT_IN are allowed for non-string types","handlingStrategy":"validation","validationCode":"op := item.Operator\nif item.Key.DataType != v3.AttributeKeyDataTypeString && op != v3.FilterOperatorIn && op != v3.FilterOperatorNotIn {\n    return fmt.Errorf(\"key %s must be string-typed or use in/not-in\", item.Key.Key)\n}","typeGuard":"func isStringOrListOp(dt v3.AttributeKeyDataType, op v3.FilterOperator) bool {\n    return dt == v3.AttributeKeyDataTypeString || op == v3.FilterOperatorIn || op == v3.FilterOperatorNotIn\n}","tryCatchPattern":null,"preventionTips":["Fetch attribute key metadata before building filters","Restrict the operator dropdown based on the key's DataType"],"tags":["signoz","logs","resource-filters","query-builder","validation"],"backgroundTag":"filter-type-mismatch","analyzedSha":"5069bf80b08f1f00d7e014eccc09902f9871004f","analyzedAt":"2026-08-28T06:22:12.824Z","schemaVersion":2},"datasetVersion":"2026-08-28T11:17:15.048Z"}