SigNoz/signoz · error

invalid data type, expected float, got %v

Error message

invalid data type, expected float, got %v

What it means

For a Float64 attribute key, an element inside a []interface{} value failed strconv.ParseFloat when it was a string, or fell through the float32/int/int64/float64 cases (reported at line 120 for the string-parse failure inside the array loop).

Source

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

		case float64:
			return int64(x), nil
		case string:
			int64val, err := strconv.ParseInt(x, 10, 64)
			if err != nil {
				return nil, fmt.Errorf("invalid data type, expected int, got %v", reflect.TypeOf(v))
			}
			return int64val, nil
		default:
			return nil, fmt.Errorf("invalid data type, expected int, got %v", reflect.TypeOf(v))
		}
	case v3.AttributeKeyDataTypeFloat64:
		switch x := v.(type) {
		case []interface{}:
			for i, val := range x {
				if _, ok := val.(string); ok {
					float64val, err := strconv.ParseFloat(val.(string), 64)
					if err != nil {
						return nil, fmt.Errorf("invalid data type, expected float, got %v", reflect.TypeOf(val))
					}
					x[i] = float64val
				} else if _, ok := val.(float32); ok {
					x[i] = float64(val.(float32))
				} else if _, ok := val.(int); ok {
					x[i] = float64(val.(int))
				} else if _, ok := val.(int64); ok {
					x[i] = float64(val.(int64))
				} else if _, ok := val.(float64); !ok {
					return nil, fmt.Errorf("invalid data type, expected float, got %v", reflect.TypeOf(val))
				} else {
					x[i] = val.(float64)
				}
			}
			return x, nil
		case float32, float64:
			return x, nil
		case string:

View on GitHub (pinned to 5069bf80b0)

Solutions

  1. Validate each array element parses as a base-10 float before sending
  2. Normalize locale decimal separators and trim whitespace
  3. Use JSON numbers instead of strings for float filter values

Example fix

// before
value := []interface{}{"1,5"}
// after
value := []interface{}{1.5}
Defensive patterns

Strategy: validation

Validate before calling

for _, e := range arr {
	if s, ok := e.(string); ok {
		if _, err := strconv.ParseFloat(strings.TrimSpace(s), 64); err != nil { return badRequest("invalid float %q", s) }
	}
}

Type guard

func isFloatArr(v interface{}) bool {
	arr, ok := v.([]interface{}); if !ok { return false }
	for _, e := range arr {
		switch e.(type) { case float32, float64, int, int64: continue; case string: if _, err := strconv.ParseFloat(e.(string), 64); err != nil { return false } ; default: return false }
	}
	return true
}

Try / catch

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

Prevention

When it happens

Trigger: Filter item with dataType AttributeKeyDataTypeFloat64 whose value array contains a non-parsable string like "high", "1,5", or "".

Common situations: Free-text input into a float filter in the UI; locale-formatted decimals (comma separator); empty strings from form defaults.

Related errors


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