{"record":{"id":"dbd721fc6469dbfd","repo":"SigNoz/signoz","slug":"invalid-data-type-expected-string-got-v","errorCode":null,"errorMessage":"invalid data type, expected string, got %v","messagePattern":"invalid data type, expected string, got (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/query-service/utils/format.go","lineNumber":42,"sourceCode":"\t\tcase string, int, int64, float32, float64, bool:\n\t\t\treturn fmt.Sprintf(\"%v\", x), nil\n\t\tcase []interface{}:\n\t\t\tfor i, val := range x {\n\t\t\t\t// if val is not string and it is int, int64, float, bool, convert it to string\n\t\t\t\tif _, ok := val.(string); ok {\n\t\t\t\t\tcontinue\n\t\t\t\t} else if _, ok := val.(int); ok {\n\t\t\t\t\tx[i] = fmt.Sprintf(\"%v\", val)\n\t\t\t\t} else if _, ok := val.(int64); ok {\n\t\t\t\t\tx[i] = fmt.Sprintf(\"%v\", val)\n\t\t\t\t} else if _, ok := val.(float32); ok {\n\t\t\t\t\tx[i] = fmt.Sprintf(\"%v\", val)\n\t\t\t\t} else if _, ok := val.(float64); ok {\n\t\t\t\t\tx[i] = fmt.Sprintf(\"%v\", val)\n\t\t\t\t} else if _, ok := val.(bool); ok {\n\t\t\t\t\tx[i] = fmt.Sprintf(\"%v\", val)\n\t\t\t\t} else {\n\t\t\t\t\treturn nil, fmt.Errorf(\"invalid data type, expected string, got %v\", reflect.TypeOf(val))\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn x, nil\n\t\tcase []string:\n\t\t\treturn x, nil\n\t\tdefault:\n\t\t\treturn nil, fmt.Errorf(\"invalid data type, expected string, got %v\", reflect.TypeOf(v))\n\t\t}\n\tcase v3.AttributeKeyDataTypeBool:\n\t\tswitch x := v.(type) {\n\t\tcase []interface{}:\n\t\t\tfor i, val := range x {\n\t\t\t\tif _, ok := val.(string); ok {\n\t\t\t\t\tboolean, err := strconv.ParseBool(val.(string))\n\t\t\t\t\tif err != nil {\n\t\t\t\t\t\treturn nil, fmt.Errorf(\"invalid data type, expected bool, got %v\", reflect.TypeOf(val))\n\t\t\t\t\t}\n\t\t\t\t\tx[i] = boolean","sourceCodeStart":24,"sourceCodeEnd":60,"githubUrl":"https://github.com/SigNoz/signoz/blob/5069bf80b08f1f00d7e014eccc09902f9871004f/pkg/query-service/utils/format.go#L24-L60","documentation":"ValidateAndCastValue, when the filter item's key DataType is string and the value is a []interface{}, coerces each element (string/float64/bool are formatted with %v). This error fires for an element of any other type — e.g. nil, map, or nested slice.","triggerScenarios":"Passing a filter value array like [null] or [{\"a\":1}] for an attribute whose data type is string; used by buildTracesFilterQuery / BuildTracesFilterQuery when constructing ClickHouse traces filters.","commonSituations":"JSON bodies with nulls in value arrays; clients sending nested objects as values; GraphQL/JSON-decoded []interface{} holding unexpected types.","solutions":["Send only scalar values (strings/numbers/booleans) in the value array for string-typed keys","Filter out nulls client-side before submitting the query"],"exampleFix":"// before\n{\"value\":[null,\"frontend\"]}\n// after\n{\"value\":[\"frontend\"]}","handlingStrategy":"type-guard","validationCode":"for _, el := range valueArr { switch el.(type) { case string, float64, bool: default: return fmt.Errorf(\"invalid element %T\", el) } }","typeGuard":"func isScalarStringCastable(el interface{}) bool { switch el.(type) { case string, float64, bool: return true }; return false }","tryCatchPattern":null,"preventionTips":["Never include nulls in filter value arrays","Send only scalars for string-typed keys"],"tags":["signoz","filters","traces","type-mismatch"],"backgroundTag":"filter-value-type-mismatch","analyzedSha":"5069bf80b08f1f00d7e014eccc09902f9871004f","analyzedAt":"2026-08-28T06:22:12.824Z","schemaVersion":2},"datasetVersion":"2026-08-28T11:17:15.048Z"}