{"record":{"id":"051cbb8a1e31e79f","repo":"GopeedLab/gopeed","slug":"unknown-method-s","errorCode":null,"errorMessage":"Unknown method: %s","messagePattern":"Unknown method: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/host/main.go","lineNumber":178,"sourceCode":"\t\tif _, err := io.ReadFull(os.Stdin, input); err != nil {\n\t\t\tsendError(\"Failed to read message: \" + err.Error())\n\t\t\treturn\n\t\t}\n\n\t\t// Parse message\n\t\tvar message Message\n\t\tif err := json.Unmarshal(input, &message); err != nil {\n\t\t\tsendError(\"Failed to parse message: \" + err.Error())\n\t\t\treturn\n\t\t}\n\n\t\t// Handle request\n\t\tvar data any\n\t\tvar err error\n\t\tif handler, ok := apiMap[message.Method]; ok {\n\t\t\tdata, err = handler(&message)\n\t\t} else {\n\t\t\terr = errors.New(\"Unknown method: \" + message.Method)\n\t\t}\n\t\tif err != nil {\n\t\t\tsendError(err.Error())\n\t\t\tcontinue\n\t\t}\n\t\tsendResponse(0, data, \"\")\n\t}\n}\n\nfunc sendResponse(code int, data interface{}, message string) {\n\tresponse := Response{\n\t\tCode:    code,\n\t\tData:    data,\n\t\tMessage: message,\n\t}\n\n\t// Encode response\n\tresponseBytes, err := json.Marshal(response)","sourceCodeStart":160,"sourceCodeEnd":196,"githubUrl":"https://github.com/GopeedLab/gopeed/blob/7b7327ffb30816273a74b142cccc0bc10c5a4c67/cmd/host/main.go#L160-L196","documentation":"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).","triggerScenarios":"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.","commonSituations":"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.","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"],"exampleFix":"// before (writing to host binary stdin)\nwriteFrame(map[string]any{\"method\": \"create-download\", \"params\": task})\n\n// after\nwriteFrame(map[string]any{\"method\": \"create\", \"meta\": map[string]any{\"silent\": false}, \"params\": task})","handlingStrategy":"validation","validationCode":"var allowedMethods = map[string]bool{\n  \"ping\": true, \"wakeup\": true, \"create\": true, \"forward\": true,\n}\nif !allowedMethods[message.Method] {\n  return fmt.Errorf(\"method %q is not supported by host binary; allowed: ping, wakeup, create, forward\", message.Method)\n}","typeGuard":"func isKnownHostMethod(m string) bool {\n  switch m {\n  case \"ping\", \"wakeup\", \"create\", \"forward\":\n    return true\n  }\n  return false\n}","tryCatchPattern":"resp := roundTrip(msg)\nif resp.Code != 0 && strings.HasPrefix(resp.Message, \"Unknown method:\") {\n  // correct the method name against the allowlist and resend the frame\n}","preventionTips":["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"],"tags":["go","stdin-protocol","rpc","host-binary","json","method-dispatch"],"backgroundTag":null,"analyzedSha":"7b7327ffb30816273a74b142cccc0bc10c5a4c67","analyzedAt":"2026-08-16T02:51:03.250Z","schemaVersion":2},"datasetVersion":"2026-08-16T03:17:38.424Z"}