{"record":{"id":"f5af7161cd549dc2","repo":"SigNoz/signoz","slug":"invalid-data-type-expected-int-got-v","errorCode":null,"errorMessage":"invalid data type, expected int, got %v","messagePattern":"invalid data type, expected int, got (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/query-service/utils/format.go","lineNumber":86,"sourceCode":"\t\tcase bool:\n\t\t\treturn x, nil\n\t\tcase string:\n\t\t\tboolean, err := strconv.ParseBool(x)\n\t\t\tif err != nil {\n\t\t\t\treturn nil, fmt.Errorf(\"invalid data type, expected bool, got %v\", reflect.TypeOf(v))\n\t\t\t}\n\t\t\treturn boolean, nil\n\t\tdefault:\n\t\t\treturn nil, fmt.Errorf(\"invalid data type, expected bool, got %v\", reflect.TypeOf(v))\n\t\t}\n\tcase v3.AttributeKeyDataTypeInt64:\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\tint64val, err := strconv.ParseInt(val.(string), 10, 64)\n\t\t\t\t\tif err != nil {\n\t\t\t\t\t\treturn nil, fmt.Errorf(\"invalid data type, expected int, got %v\", reflect.TypeOf(val))\n\t\t\t\t\t}\n\t\t\t\t\tx[i] = int64val\n\t\t\t\t} else if _, ok := val.(int); ok {\n\t\t\t\t\tx[i] = int64(val.(int))\n\t\t\t\t} else if _, ok := val.(int64); !ok {\n\t\t\t\t\treturn nil, fmt.Errorf(\"invalid data type, expected int, got %v\", reflect.TypeOf(val))\n\t\t\t\t} else {\n\t\t\t\t\tx[i] = val.(int64)\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn x, nil\n\t\tcase int, int64:\n\t\t\treturn x, nil\n\t\tcase float32:\n\t\t\treturn int64(x), nil\n\t\tcase float64:\n\t\t\treturn int64(x), nil\n\t\tcase string:","sourceCodeStart":68,"sourceCodeEnd":104,"githubUrl":"https://github.com/SigNoz/signoz/blob/5069bf80b08f1f00d7e014eccc09902f9871004f/pkg/query-service/utils/format.go#L68-L104","documentation":"Thrown by ValidateAndCastValue in SigNoz query-service when an attribute filter value declared as an int-typed attribute (e.g. []int64 via a string array) contains an element that is neither a numeric-parsable string nor int/int64, e.g. a bool, float, or nil inside the array.","triggerScenarios":"Calling buildTracesFilterQuery / BuildTracesFilterQuery or buildResourceFiltersFromFilterItems with a filter item whose key dataType is v3.AttributeKeyDataTypeInt64 and whose value is []interface{} containing a non-int element (bool, float64, null, nested object).","commonSituations":"Frontend or API client sends {\"value\": [1.5, \"abc\", true]} for an int64 attribute key; JSON numbers decoded as float64 by encoding/json; schema drift where an attribute was logged once as float/string and now filtered as int.","solutions":["Ensure all elements of the value array are int64 or strings parsable by strconv.ParseInt (base 10, 64-bit)","Pre-normalize JSON-decoded numbers (encoding/json yields float64) to int64 before calling the query builder","If float values are legitimate, change the filter key's dataType to Float64 instead of Int64","Send values as int64-typed JSON numbers without decimal points or scientific notation"],"exampleFix":"// before\nfilter.Value = []interface{}{1.5, \"2\"}\n// after\nfilter.Value = []interface{}{int64(1), int64(2)}","handlingStrategy":"validation","validationCode":"func validIntArr(v interface{}) bool {\n\tarr, ok := v.([]interface{})\n\tif !ok { return false }\n\tfor _, e := range arr {\n\t\tswitch e.(type) {\n\t\tcase int, int64, string:\n\t\t\tif s, isS := e.(string); isS {\n\t\t\t\tif _, err := strconv.ParseInt(s, 10, 64); err != nil { return false }\n\t\t\t}\n\t\tdefault:\n\t\t\treturn false\n\t\t}\n\t}\n\treturn true\n}","typeGuard":"func isIntFilterValue(v interface{}) bool {\n\tswitch v.(type) {\n\tcase int, int64, string: return true\n\tcase []interface{}: return validIntArr(v)\n\t}\n\treturn false\n}","tryCatchPattern":"if _, err := utils.ValidateAndCastValue(v, v3.AttributeKeyDataTypeInt64); err != nil { return httperr.BadRequest(fmt.Sprintf(\"invalid int filter value: %v\", err)) }","preventionTips":["Type filter values client-side before building v3.FilterItem","Avoid interface{} round-trips through encoding/json for numeric filters; use json.Number or typed structs","Keep filter key dataType in sync with the data actually ingested for the attribute"],"tags":["signoz","query-service","type-mismatch","filter-validation","go"],"backgroundTag":"filter-value-type-mismatch","analyzedSha":"5069bf80b08f1f00d7e014eccc09902f9871004f","analyzedAt":"2026-08-28T06:22:12.824Z","schemaVersion":2},"datasetVersion":"2026-08-28T11:17:15.048Z"}