{"record":{"id":"abb7677f199aa078","repo":"wavetermdev/waveterm","slug":"command-q-not-found","errorCode":null,"errorMessage":"command %q not found","messagePattern":"command %q not found","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/wshutil/wshadapter.go","lineNumber":63,"sourceCode":"\t\t}\n\t\treturn rtnVals[0].Interface(), errIf.(error)\n\tdefault:\n\t\treturn nil, fmt.Errorf(\"too many return values: %d\", len(rtnVals))\n\t}\n}\n\nfunc noImplHandler(handler *RpcResponseHandler) bool {\n\thandler.SendResponseError(fmt.Errorf(\"command %q not implemented\", handler.GetCommand()))\n\treturn true\n}\n\nfunc recodeCommandData(command string, data any, commandDataType reflect.Type) (any, error) {\n\tif command == \"\" || commandDataType == nil {\n\t\treturn data, nil\n\t}\n\tmethodDecl := WshCommandDeclMap[command]\n\tif methodDecl == nil {\n\t\treturn data, fmt.Errorf(\"command %q not found\", command)\n\t}\n\tcommandDataPtr := reflect.New(commandDataType).Interface()\n\tif data != nil {\n\t\terr := utilfn.ReUnmarshal(commandDataPtr, data)\n\t\tif err != nil {\n\t\t\treturn data, fmt.Errorf(\"error re-marshalling command data: %w\", err)\n\t\t}\n\t}\n\treturn reflect.ValueOf(commandDataPtr).Elem().Interface(), nil\n}\n\nfunc serverImplAdapter(impl any) func(*RpcResponseHandler) bool {\n\tif impl == nil {\n\t\treturn noImplHandler\n\t}\n\trtype := reflect.TypeOf(impl)\n\tif rtype.Kind() != reflect.Ptr && rtype.Elem().Kind() != reflect.Struct {\n\t\tpanic(fmt.Sprintf(\"expected struct pointer, got %s\", rtype))","sourceCodeStart":45,"sourceCodeEnd":81,"githubUrl":"https://github.com/wavetermdev/waveterm/blob/a4447c1563b2df285ab89e76c82f91e1a1a49c1e/pkg/wshutil/wshadapter.go#L45-L81","documentation":"recodeCommandData looks up the command name in WshCommandDeclMap to find its declared payload type. If the command name is not present in the declaration map (and command/data types were supplied), it returns this error instead of attempting to re-marshal the payload. It signals that the command being invoked is not part of the declared wsh RPC surface.","triggerScenarios":"Sending an RPC whose command string does not match any key in WshCommandDeclMap (typo, renamed command, client newer than the declaration set compiled into the peer), while passing a non-nil commandDataType so recoding is attempted.","commonSituations":"Version skew between wsh client and server (command renamed/added in a newer release); hand-crafted command strings in scripts; third-party code calling internal recode paths with a custom command name.","solutions":["Print the exact command string and compare it against the wshrpc.Command_* constants; fix typos or casing.","Align client and server versions so both share the same command declarations.","If the command is intentionally custom, pass an empty command string or nil commandDataType so recodeCommandData passes the data through unchanged."],"exampleFix":"// before: arbitrary command string\nerr := client.SendRpcRequest(ctx, \"remotefileread\", data) // command not in decl map\n// after: use the declared constant\nerr := client.SendRpcRequest(ctx, wshrpc.Command_RemoteReadFile, data)","handlingStrategy":"validation","validationCode":"if _, ok := wshutil.WshCommandDeclMap[command]; !ok {\n    return fmt.Errorf(\"unknown command %q; see wshrpc.Command_* constants\", command)\n}","typeGuard":null,"tryCatchPattern":"err := client.SendRpcRequest(ctx, command, data)\nif err != nil && strings.Contains(err.Error(), \"not found\") && strings.Contains(err.Error(), \"command\") {\n    return fmt.Errorf(\"command %s is not declared on this build; check version sync\", command)\n}","preventionTips":["Always use wshrpc.Command_* constants, never hand-typed command strings.","Keep client and server binaries built from the same source revision.","Add a startup sanity check that verifies the commands you use exist in WshCommandDeclMap."],"tags":["rpc","wsh","unknown-command","waveterm"],"backgroundTag":"unknown-rpc-command","analyzedSha":"a4447c1563b2df285ab89e76c82f91e1a1a49c1e","analyzedAt":"2026-09-01T15:26:23.972Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}