{"record":{"id":"5376f2b8bcc03365","repo":"wavetermdev/waveterm","slug":"cannot-convert-t-to-s","errorCode":null,"errorMessage":"cannot convert %T to %s","messagePattern":"cannot convert %T to (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/service/service.go","lineNumber":104,"sourceCode":"\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)\n\t}\n\tcmd, err := webcmd.ParseWSCommandMap(jsonArg.(map[string]any))\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"error parsing command map: %w\", err)\n\t}\n\treturn cmd, nil\n}\n\nfunc convertSpecial(argType reflect.Type, jsonArg any) (any, error) {\n\tjsonType := reflect.TypeOf(jsonArg)\n\tif argType == orefRType {\n\t\tif jsonType.Kind() != reflect.String {\n\t\t\treturn nil, fmt.Errorf(\"cannot convert %T to %s\", jsonArg, argType)\n\t\t}\n\t\toref, err := waveobj.ParseORef(jsonArg.(string))\n\t\tif err != nil {\n\t\t\treturn nil, fmt.Errorf(\"invalid oref string: %v\", err)\n\t\t}","sourceCodeStart":86,"sourceCodeEnd":122,"githubUrl":"https://github.com/wavetermdev/waveterm/blob/a4447c1563b2df285ab89e76c82f91e1a1a49c1e/pkg/service/service.go#L86-L122","documentation":"convertWSCommand converts a JSON argument into a webcmd.WSCommand. The JSON value must be a map[string]any; any other JSON type (string, number, array, nil) cannot represent a command and triggers 'cannot convert %T to %s'.","triggerScenarios":"An RPC method takes a WSCommand parameter but the caller passes a string (e.g. a command name) or array instead of a JSON object like {\"command\":\"run\",\"args\":[...]}.","commonSituations":"Frontend sends the command as a serialized string instead of an object; callers confuse WSCommand with a command string ID; client/server schema drift.","solutions":["Pass the command as a JSON object with the expected WSCommand fields (command, args, etc.).","Wrap string command names into the proper object shape before invoking.","Ensure client and server versions agree on the WSCommand argument shape."],"exampleFix":"// before\ninvokeRpc(\"run-command\", \"run:shell\")\n// after\ninvokeRpc(\"run-command\", map[string]any{\"command\": \"run\", \"args\": []any{\"shell\"}})","handlingStrategy":"type-guard","validationCode":"if _, ok := arg.(map[string]any); !ok {\n    return fmt.Errorf(\"WSCommand arg must be a JSON object, got %T\", arg)\n}","typeGuard":"func isWSCommandArg(v any) bool {\n    _, ok := v.(map[string]any)\n    return ok\n}","tryCatchPattern":null,"preventionTips":["Serialize WSCommand from its struct via the SDK; never hand-build alternatives.","Keep client and server argument schemas in sync via shared types.","Add tests for every RPC invocation path."],"tags":["type-conversion","rpc","wscommand","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"}