{"record":{"id":"472b7a3b45bc1956","repo":"SigNoz/signoz","slug":"invalid-attribute-datatype-s","errorCode":null,"errorMessage":"invalid attribute dataType: %s","messagePattern":"invalid attribute dataType: (.+?)","errorType":"validation","errorClass":null,"httpStatus":400,"severity":"error","filePath":"pkg/query-service/model/v3/v3.go","lineNumber":403,"sourceCode":"\ntype AttributeKey struct {\n\tKey      string               `json:\"key\"`\n\tDataType AttributeKeyDataType `json:\"dataType\"`\n\tType     AttributeKeyType     `json:\"type\"`\n\tIsColumn bool                 `json:\"isColumn\"`\n\tIsJSON   bool                 `json:\"isJSON\"`\n}\n\nfunc (a AttributeKey) CacheKey() string {\n\treturn fmt.Sprintf(\"%s-%s-%s-%t\", a.Key, a.DataType, a.Type, a.IsColumn)\n}\n\nfunc (a AttributeKey) Validate() error {\n\tswitch a.DataType {\n\tcase AttributeKeyDataTypeBool, AttributeKeyDataTypeInt64, AttributeKeyDataTypeFloat64, AttributeKeyDataTypeString, AttributeKeyDataTypeArrayFloat64, AttributeKeyDataTypeArrayString, AttributeKeyDataTypeArrayInt64, AttributeKeyDataTypeArrayBool, AttributeKeyDataTypeUnspecified:\n\t\tbreak\n\tdefault:\n\t\treturn fmt.Errorf(\"invalid attribute dataType: %s\", a.DataType)\n\t}\n\n\tif a.IsColumn {\n\t\tswitch a.Type {\n\t\tcase AttributeKeyTypeResource, AttributeKeyTypeTag, AttributeKeyTypeUnspecified, AttributeKeyTypeInstrumentationScope:\n\t\t\tbreak\n\t\tdefault:\n\t\t\treturn fmt.Errorf(\"invalid attribute type: %s\", a.Type)\n\t\t}\n\t}\n\n\tif a.Key == \"\" {\n\t\treturn fmt.Errorf(\"key is empty\")\n\t}\n\n\treturn nil\n}\n","sourceCodeStart":385,"sourceCodeEnd":421,"githubUrl":"https://github.com/SigNoz/signoz/blob/5069bf80b08f1f00d7e014eccc09902f9871004f/pkg/query-service/model/v3/v3.go#L385-L421","documentation":"AttributeKey.Validate() rejects a DataType outside the full supported set, which includes scalars (bool, int64, float64, string, unspecified) AND array types (arrayBool, arrayInt64, arrayFloat64, arrayString). This is the wider type set used for filter keys inside query payloads.","triggerScenarios":"Building a FilterItem or expression whose key has dataType like \"number\", \"array\", \"datetime\", or \"\" inside a /api/v3/query_range builder request; AttributeKey.Validate() is called during BuilderQuery validation.","commonSituations":"Frontends mapping JS types directly, payloads from older API versions without array types, or copy-pasted dataType values from the autocomplete endpoints that use different spellings.","solutions":["Use exact enum strings: \"bool\", \"int64\", \"float64\", \"string\", \"unspecified\", \"arrayBool\", \"arrayInt64\", \"arrayFloat64\", \"arrayString\"","Map JS types: number→\"float64\"/\"int64\", string[]→\"arrayString\"","When receiving keys from the server's own autocomplete APIs, pass their dataType through unchanged"],"exampleFix":"// before\n{\"key\":\"tags\",\"dataType\":\"array\",\"value\":[\"a\"]}\n\n// after\n{\"key\":\"tags\",\"dataType\":\"arrayString\",\"value\":[\"a\"]}","handlingStrategy":"validation","validationCode":"switch key.DataType { case v3.AttributeKeyDataTypeBool, v3.AttributeKeyDataTypeInt64, v3.AttributeKeyDataTypeFloat64, v3.AttributeKeyDataTypeString, v3.AttributeKeyDataTypeArrayFloat64, v3.AttributeKeyDataTypeArrayString, v3.AttributeKeyDataTypeArrayInt64, v3.AttributeKeyDataTypeArrayBool, v3.AttributeKeyDataTypeUnspecified: default: return fmt.Errorf(\"bad dataType %q\", key.DataType) }","typeGuard":"func isValidAttributeKeyDataType(d v3.AttributeKeyDataType) bool { switch d { case v3.AttributeKeyDataTypeBool, v3.AttributeKeyDataTypeInt64, v3.AttributeKeyDataTypeFloat64, v3.AttributeKeyDataTypeString, v3.AttributeKeyDataTypeArrayFloat64, v3.AttributeKeyDataTypeArrayString, v3.AttributeKeyDataTypeArrayInt64, v3.AttributeKeyDataTypeArrayBool, v3.AttributeKeyDataTypeUnspecified: return true }; return false }","tryCatchPattern":null,"preventionTips":["Reuse AttributeKey structs returned by the API","Map JS arrays to the arrayString/arrayFloat64 spellings"],"tags":["go","validation","enum","data-type","query-builder"],"backgroundTag":"invalid-enum-value","analyzedSha":"5069bf80b08f1f00d7e014eccc09902f9871004f","analyzedAt":"2026-08-28T06:22:12.824Z","schemaVersion":2},"datasetVersion":"2026-08-28T11:17:15.048Z"}