{"record":{"id":"aa1a1006cc47fdfc","repo":"wavetermdev/waveterm","slug":"command-q-invalid-multi-arg-payload","errorCode":null,"errorMessage":"command %q invalid multi arg payload","messagePattern":"command %q invalid multi arg payload","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/wshutil/wshadapter.go","lineNumber":119,"sourceCode":"\t\tvar callParams []reflect.Value\n\t\tcallParams = append(callParams, reflect.ValueOf(handler.Context()))\n\t\tcommandDataTypes := methodDecl.GetCommandDataTypes()\n\t\tif len(commandDataTypes) == 1 {\n\t\t\tcmdData, err := recodeCommandData(cmd, handler.GetCommandRawData(), commandDataTypes[0])\n\t\t\tif err != nil {\n\t\t\t\thandler.SendResponseError(err)\n\t\t\t\treturn true\n\t\t\t}\n\t\t\tcallParams = append(callParams, reflect.ValueOf(cmdData))\n\t\t} else if len(commandDataTypes) > 1 {\n\t\t\tmultiArgAny, err := recodeCommandData(cmd, handler.GetCommandRawData(), multiArgRType)\n\t\t\tif err != nil {\n\t\t\t\thandler.SendResponseError(err)\n\t\t\t\treturn true\n\t\t\t}\n\t\t\tmultiArg, ok := multiArgAny.(wshrpc.MultiArg)\n\t\t\tif !ok {\n\t\t\t\thandler.SendResponseError(fmt.Errorf(\"command %q invalid multi arg payload\", cmd))\n\t\t\t\treturn true\n\t\t\t}\n\t\t\tif len(multiArg.Args) != len(commandDataTypes) {\n\t\t\t\thandler.SendResponseError(fmt.Errorf(\"command %q expected %d args, got %d\", cmd, len(commandDataTypes), len(multiArg.Args)))\n\t\t\t\treturn true\n\t\t\t}\n\t\t\tfor idx, commandDataType := range commandDataTypes {\n\t\t\t\tcmdData, err := recodeCommandData(cmd, multiArg.Args[idx], commandDataType)\n\t\t\t\tif err != nil {\n\t\t\t\t\thandler.SendResponseError(err)\n\t\t\t\t\treturn true\n\t\t\t\t}\n\t\t\t\tcallParams = append(callParams, reflect.ValueOf(cmdData))\n\t\t\t}\n\t\t}\n\t\tif methodDecl.CommandType == wshrpc.RpcType_Call {\n\t\t\trtnVals := implMethod.Call(callParams)\n\t\t\trtnData, rtnErr := decodeRtnVals(rtnVals)","sourceCodeStart":101,"sourceCodeEnd":137,"githubUrl":"https://github.com/wavetermdev/waveterm/blob/a4447c1563b2df285ab89e76c82f91e1a1a49c1e/pkg/wshutil/wshadapter.go#L101-L137","documentation":"For commands declared with multiple argument types, the adapter expects the payload to be a wshrpc.MultiArg struct (a struct wrapping an Args slice) and type-asserts the decoded payload to it. If the payload does not implement/convert to MultiArg, this error is returned. It protects the variadic-style RPC commands from receiving a single raw value.","triggerScenarios":"Calling a multi-argument command (methodDecl has >1 command data types) with a plain payload instead of wshrpc.MultiArg{Args: [...]}; sending a single arg directly rather than wrapped in the Args slice.","commonSituations":"Hand-building RPC payloads in scripts or tests for commands like SetDomainVar/AppendDomainVar that take multiple typed args; forgetting the MultiArg wrapper after changing a command from single-arg to multi-arg.","solutions":["Wrap the arguments in wshrpc.MultiArg{Args: []any{arg1, arg2, ...}} with one entry per declared argument type.","Check methodDecl.GetCommandDataTypes() for the command to confirm it is genuinely multi-arg before choosing a payload shape.","If the command now takes a single argument in your version, upgrade/downgrade so both sides agree on the declaration."],"exampleFix":"// before: single raw value for a multi-arg command\npayload := domainScope\n// after: wrap in MultiArg\npayload := wshrpc.MultiArg{Args: []any{domainScope, varName, value}}","handlingStrategy":"type-guard","validationCode":"// Only send MultiArg payloads to commands declared multi-arg\ndecl := wshutil.WshCommandDeclMap[cmd]\nif decl != nil && len(decl.GetCommandDataTypes()) > 1 {\n    payload = wshrpc.MultiArg{Args: args}\n}","typeGuard":"func asMultiArg(v any) (*wshrpc.MultiArg, bool) {\n    ma, ok := v.(wshrpc.MultiArg)\n    if !ok { return nil, false }\n    return &ma, true\n}","tryCatchPattern":"err := client.SendRpcRequest(ctx, cmd, payload)\nif err != nil && strings.Contains(err.Error(), \"invalid multi arg payload\") {\n    return fmt.Errorf(\"%s requires wshrpc.MultiArg{Args: [...]}, got %T\", cmd, payload)\n}","preventionTips":["Wrap multiple arguments in wshrpc.MultiArg before sending.","Check GetCommandDataTypes() for the command to learn the required arity and types.","Write helper constructors per command instead of hand-building payloads."],"tags":["rpc","wsh","payload","reflection","waveterm"],"backgroundTag":"rpc-payload-marshal-failed","analyzedSha":"a4447c1563b2df285ab89e76c82f91e1a1a49c1e","analyzedAt":"2026-09-01T15:26:23.972Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}