wavetermdev/waveterm · error
command %q not found
Error message
command %q not found
What it means
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.
Source
Thrown at pkg/wshutil/wshadapter.go:63
}
return rtnVals[0].Interface(), errIf.(error)
default:
return nil, fmt.Errorf("too many return values: %d", len(rtnVals))
}
}
func noImplHandler(handler *RpcResponseHandler) bool {
handler.SendResponseError(fmt.Errorf("command %q not implemented", handler.GetCommand()))
return true
}
func recodeCommandData(command string, data any, commandDataType reflect.Type) (any, error) {
if command == "" || commandDataType == nil {
return data, nil
}
methodDecl := WshCommandDeclMap[command]
if methodDecl == nil {
return data, fmt.Errorf("command %q not found", command)
}
commandDataPtr := reflect.New(commandDataType).Interface()
if data != nil {
err := utilfn.ReUnmarshal(commandDataPtr, data)
if err != nil {
return data, fmt.Errorf("error re-marshalling command data: %w", err)
}
}
return reflect.ValueOf(commandDataPtr).Elem().Interface(), nil
}
func serverImplAdapter(impl any) func(*RpcResponseHandler) bool {
if impl == nil {
return noImplHandler
}
rtype := reflect.TypeOf(impl)
if rtype.Kind() != reflect.Ptr && rtype.Elem().Kind() != reflect.Struct {
panic(fmt.Sprintf("expected struct pointer, got %s", rtype))View on GitHub (pinned to a4447c1563)
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.
Example fix
// before: arbitrary command string err := client.SendRpcRequest(ctx, "remotefileread", data) // command not in decl map // after: use the declared constant err := client.SendRpcRequest(ctx, wshrpc.Command_RemoteReadFile, data)
Defensive patterns
Strategy: validation
Validate before calling
if _, ok := wshutil.WshCommandDeclMap[command]; !ok {
return fmt.Errorf("unknown command %q; see wshrpc.Command_* constants", command)
} Try / catch
err := client.SendRpcRequest(ctx, command, data)
if err != nil && strings.Contains(err.Error(), "not found") && strings.Contains(err.Error(), "command") {
return fmt.Errorf("command %s is not declared on this build; check version sync", command)
} Prevention
- 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.
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- command %q not implemented
- error re-marshalling command data: %w
- command not implemented %q
- command %q invalid multi arg payload
- command %q expected %d args, got %d
AI-assisted analysis of wavetermdev/waveterm@a4447c1563 (2026-09-01).
Data as JSON: /api/errors/abb7677f199aa078.
Report an issue: GitHub.