{"record":{"id":"4d279e8d30d2e2f0","repo":"wavetermdev/waveterm","slug":"invalid-number-type-s","errorCode":null,"errorMessage":"invalid number type %s","messagePattern":"invalid number type (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/service/service.go","lineNumber":86,"sourceCode":"\t\treturn int32(jsonArg), nil\n\tcase reflect.Int64:\n\t\treturn int64(jsonArg), nil\n\tcase reflect.Uint:\n\t\treturn uint(jsonArg), nil\n\tcase reflect.Uint8:\n\t\treturn uint8(jsonArg), nil\n\tcase reflect.Uint16:\n\t\treturn uint16(jsonArg), nil\n\tcase reflect.Uint32:\n\t\treturn uint32(jsonArg), nil\n\tcase reflect.Uint64:\n\t\treturn uint64(jsonArg), nil\n\tcase reflect.Float32:\n\t\treturn float32(jsonArg), nil\n\tcase reflect.Float64:\n\t\treturn jsonArg, nil\n\t}\n\treturn nil, fmt.Errorf(\"invalid number type %s\", argType)\n}\n\nfunc convertComplex(argType reflect.Type, jsonArg any) (any, error) {\n\tnativeArgVal := reflect.New(argType)\n\terr := utilfn.DoMapStructure(nativeArgVal.Interface(), jsonArg)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn nativeArgVal.Elem().Interface(), nil\n}\n\nfunc isSpecialWaveArgType(argType reflect.Type) bool {\n\treturn argType == waveObjRType || argType == waveObjSliceRType || argType == waveObjMapRType || argType == wsCommandRType\n}\n\nfunc convertWSCommand(argType reflect.Type, jsonArg any) (any, error) {\n\tif _, ok := jsonArg.(map[string]any); !ok {\n\t\treturn nil, fmt.Errorf(\"cannot convert %T to %s\", jsonArg, argType)","sourceCodeStart":68,"sourceCodeEnd":104,"githubUrl":"https://github.com/wavetermdev/waveterm/blob/a4447c1563b2df285ab89e76c82f91e1a1a49c1e/pkg/service/service.go#L68-L104","documentation":"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>'.","triggerScenarios":"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.","commonSituations":"Developers adding new Wave RPC endpoints that take int32 or custom numeric types; reflection-based dispatch hits an unhandled parameter type at runtime.","solutions":["Change the RPC signature to a supported type: int, int64, uint64, float32, or float64.","Add the missing case to convertNumber so the type is converted.","Replace named custom numeric aliases in signatures with the underlying built-in type."],"exampleFix":"// before\nfunc MyRpc(ctx context.Context, count int32) error { ... }\n// after\nfunc MyRpc(ctx context.Context, count int64) error { ... }","handlingStrategy":"type-guard","validationCode":"allowed := map[string]bool{\"int\":true,\"int64\":true,\"uint64\":true,\"float32\":true,\"float64\":true}\nif !allowed[argType.Name()] {\n    return fmt.Errorf(\"unsupported RPC param type %s\", argType)\n}","typeGuard":"func isSupportedNumberType(t reflect.Type) bool {\n    switch t.Kind() {\n    case reflect.Int, reflect.Int64, reflect.Uint64, reflect.Float32, reflect.Float64:\n        return true\n    }\n    return false\n}","tryCatchPattern":null,"preventionTips":["Declare RPC numeric params only as int, int64, uint64, float32, or float64.","Add a unit test enumerating all RPC signatures and validating param types.","Avoid named custom numeric types in RPC signatures."],"tags":["reflection","type-conversion","rpc","go"],"backgroundTag":"unsupported-argument-type","analyzedSha":"a4447c1563b2df285ab89e76c82f91e1a1a49c1e","analyzedAt":"2026-09-01T15:26:23.972Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}