SigNoz/signoz · error

invalid data type, expected float, bool, int, string or []in

Error message

invalid data type, expected float, bool, int, string or []interface{} but got %v

What it means

ValidateAndCastValue was called with a dataType that is none of the supported attribute key types (bool, string, int64, float64). The whole switch fell to the outer default and the unsupported dataType value is printed.

Source

Thrown at pkg/query-service/utils/format.go:152

			}
			return x, nil
		case float32, float64:
			return x, nil
		case string:
			float64val, err := strconv.ParseFloat(x, 64)
			if err != nil {
				return nil, fmt.Errorf("invalid data type, expected float, got %v", reflect.TypeOf(v))
			}
			return float64val, nil
		case int:
			return float64(x), nil
		case int64:
			return float64(x), nil
		default:
			return nil, fmt.Errorf("invalid data type, expected float, got %v", reflect.TypeOf(v))
		}
	default:
		return nil, fmt.Errorf("invalid data type, expected float, bool, int, string or []interface{} but got %v", dataType)
	}
}

func QuoteEscapedString(str string) string {
	// https://clickhouse.com/docs/en/sql-reference/syntax#string
	str = strings.ReplaceAll(str, `\`, `\\`)
	str = strings.ReplaceAll(str, `'`, `\'`)
	return str
}

func QuoteEscapedStringForContains(str string, isIndex bool) string {
	// https: //clickhouse.com/docs/en/sql-reference/functions/string-search-functions#like
	str = QuoteEscapedString(str)

	// we are adding this because if a string contains quote `"` it will be stored as \" in clickhouse
	// to query that using like our query should be \\\\"
	if isIndex {
		// isIndex is true means that the extra slash is present

View on GitHub (pinned to 5069bf80b0)

Solutions

  1. Upgrade all SigNoz components (frontend, OtelCollector, query-service) to the same version so DataType enums match
  2. Set an explicit supported DataType (v3.AttributeKeyDataTypeBool/String/Int64/Float64) on every filter key
  3. If a custom/untyped filter is needed, default it to String before calling the builder

Example fix

// before
key := v3.AttributeKey{DataType: v3.AttributeKeyDataType(99)}
// after
key := v3.AttributeKey{DataType: v3.AttributeKeyDataTypeString}
Defensive patterns

Strategy: validation

Validate before calling

switch key.DataType {
case v3.AttributeKeyDataTypeBool, v3.AttributeKeyDataTypeString, v3.AttributeKeyDataTypeInt64, v3.AttributeKeyDataTypeFloat64:
default:
	return badRequest("unsupported filter data type %d", key.DataType)
}

Type guard

func isSupportedDataType(dt v3.AttributeKeyDataType) bool { return dt >= 0 && dt <= v3.AttributeKeyDataTypeFloat64 }

Try / catch

if _, err := utils.ValidateAndCastValue(v, key.DataType); err != nil { return 400 }

Prevention

When it happens

Trigger: Constructing a v3.AttributeKey with an unrecognized DataType value (e.g. a raw integer from an out-of-range enum, an empty DataType, or a newly added type the deployed SigNoz version doesn't handle) and passing its filter to buildTracesFilterQuery/BuildTracesFilterQuery.

Common situations: Version skew between frontend/backend and query-service (new data type added in newer SigNoz); manually crafted v3.FilterItem with unset DataType; serialized enum from another language sending numeric values.

Related errors


AI-assisted analysis of SigNoz/signoz@5069bf80b0 (2026-08-28). Data as JSON: /api/errors/e56786b696b7f5b1. Report an issue: GitHub.