GopeedLab/gopeed · error
Unknown method: %s
Error message
Unknown method: %s
What it means
Returned by the gopeed host binary (cmd/host/main.go:178): it reads length-prefixed JSON messages ({method, meta, params}) from stdin, and when message.Method has no entry in apiMap it responds with an error Response carrying 'Unknown method: <method>'. The accepted set is exactly ping, wakeup, create, and forward; note this error is sent via sendError and the read loop continues (unlike parse failures, which terminate).
Source
Thrown at cmd/host/main.go:178
if _, err := io.ReadFull(os.Stdin, input); err != nil {
sendError("Failed to read message: " + err.Error())
return
}
// Parse message
var message Message
if err := json.Unmarshal(input, &message); err != nil {
sendError("Failed to parse message: " + err.Error())
return
}
// Handle request
var data any
var err error
if handler, ok := apiMap[message.Method]; ok {
data, err = handler(&message)
} else {
err = errors.New("Unknown method: " + message.Method)
}
if err != nil {
sendError(err.Error())
continue
}
sendResponse(0, data, "")
}
}
func sendResponse(code int, data interface{}, message string) {
response := Response{
Code: code,
Data: data,
Message: message,
}
// Encode response
responseBytes, err := json.Marshal(response)View on GitHub (pinned to 7b7327ffb3)
Solutions
- Use only the four documented methods: ping, wakeup, create, forward
- Check the exact spelling and case of the method string before writing the frame to stdin
- If you added a method to apiMap, rebuild the host binary (go build as noted above main) and redeploy the asset — a stale binary rejects it
- Route webview RPC traffic to the HTTP /webview endpoint, not to this stdin protocol
Example fix
// before (writing to host binary stdin)
writeFrame(map[string]any{"method": "create-download", "params": task})
// after
writeFrame(map[string]any{"method": "create", "meta": map[string]any{"silent": false}, "params": task}) Defensive patterns
Strategy: validation
Validate before calling
var allowedMethods = map[string]bool{
"ping": true, "wakeup": true, "create": true, "forward": true,
}
if !allowedMethods[message.Method] {
return fmt.Errorf("method %q is not supported by host binary; allowed: ping, wakeup, create, forward", message.Method)
} Type guard
func isKnownHostMethod(m string) bool {
switch m {
case "ping", "wakeup", "create", "forward":
return true
}
return false
} Try / catch
resp := roundTrip(msg)
if resp.Code != 0 && strings.HasPrefix(resp.Message, "Unknown method:") {
// correct the method name against the allowlist and resend the frame
} Prevention
- Centralize the method allowlist in one client constant and validate before writing frames
- Rebuild the host binary (cmd/host) whenever apiMap changes so caller and binary stay in sync
- Remember the protocol continues after this error (loop continues) — only stdin read/parse failures terminate the process
When it happens
Trigger: Writing a message with method "create-download", "get", "version", or any typo ("Creat", "ping ") to the host binary's stdin; sending a method intended for the Flutter RPC server (/webview, /create, /forward routes) to this stdin protocol instead; a client built against a different gopeed version whose method set differs.
Common situations: Protocol drift between the host executable and the caller (rebuild assets/exec host binary after apiMap changes); integrators assuming a richer RPC surface than the four methods; testing by hand and mistyping the method name; sending browser-extension messages to the wrong transport.
Related errors
AI-assisted analysis of GopeedLab/gopeed@7b7327ffb3 (2026-08-16).
Data as JSON: /api/errors/051cbb8a1e31e79f.
Report an issue: GitHub.