wavetermdev/waveterm · error

invalid number type %s

Error message

invalid number type %s

What it means

convertNumber maps a JSON float64 argument onto a numeric reflect.Type. After handling the expected numeric kinds, any numeric target that falls through the switch is rejected with 'invalid number type <type>'.

Source

Thrown at pkg/service/service.go:86

		return int32(jsonArg), nil
	case reflect.Int64:
		return int64(jsonArg), nil
	case reflect.Uint:
		return uint(jsonArg), nil
	case reflect.Uint8:
		return uint8(jsonArg), nil
	case reflect.Uint16:
		return uint16(jsonArg), nil
	case reflect.Uint32:
		return uint32(jsonArg), nil
	case reflect.Uint64:
		return uint64(jsonArg), nil
	case reflect.Float32:
		return float32(jsonArg), nil
	case reflect.Float64:
		return jsonArg, nil
	}
	return nil, fmt.Errorf("invalid number type %s", argType)
}

func convertComplex(argType reflect.Type, jsonArg any) (any, error) {
	nativeArgVal := reflect.New(argType)
	err := utilfn.DoMapStructure(nativeArgVal.Interface(), jsonArg)
	if err != nil {
		return nil, err
	}
	return nativeArgVal.Elem().Interface(), nil
}

func isSpecialWaveArgType(argType reflect.Type) bool {
	return argType == waveObjRType || argType == waveObjSliceRType || argType == waveObjMapRType || argType == wsCommandRType
}

func convertWSCommand(argType reflect.Type, jsonArg any) (any, error) {
	if _, ok := jsonArg.(map[string]any); !ok {
		return nil, fmt.Errorf("cannot convert %T to %s", jsonArg, argType)

View on GitHub (pinned to a4447c1563)

Solutions

  1. Change the RPC signature to a supported type: int, int64, uint64, float32, or float64.
  2. Add the missing case to convertNumber so the type is converted.
  3. Replace named custom numeric aliases in signatures with the underlying built-in type.

Example fix

// before
func MyRpc(ctx context.Context, count int32) error { ... }
// after
func MyRpc(ctx context.Context, count int64) error { ... }
Defensive patterns

Strategy: type-guard

Validate before calling

allowed := map[string]bool{"int":true,"int64":true,"uint64":true,"float32":true,"float64":true}
if !allowed[argType.Name()] {
    return fmt.Errorf("unsupported RPC param type %s", argType)
}

Type guard

func isSupportedNumberType(t reflect.Type) bool {
    switch t.Kind() {
    case reflect.Int, reflect.Int64, reflect.Uint64, reflect.Float32, reflect.Float64:
        return true
    }
    return false
}

Prevention

When it happens

Trigger: An RPC method declares a numeric parameter whose reflect.Type is not handled by convertNumber's switch - e.g. int8/int16/int32/uint8/uint16/uint32, or a named type whose reflect kind is not among the enumerated cases.

Common situations: Developers adding new Wave RPC endpoints that take int32 or custom numeric types; reflection-based dispatch hits an unhandled parameter type at runtime.

Related errors


AI-assisted analysis of wavetermdev/waveterm@a4447c1563 (2026-09-01). Data as JSON: /api/errors/4d279e8d30d2e2f0. Report an issue: GitHub.