{"record":{"id":"afbe0c6b4f4b8e9c","repo":"GopeedLab/gopeed","slug":"webview-rpc-status-d","errorCode":null,"errorMessage":"webview rpc status %d","messagePattern":"webview rpc status (.+?)","errorType":"http","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/webview/rpcprovider/provider.go","lineNumber":178,"sourceCode":"\t}\n\n\treq, err := http.NewRequest(http.MethodPost, c.endpoint, bytes.NewReader(payload))\n\tif err != nil {\n\t\treturn err\n\t}\n\treq.Header.Set(\"Content-Type\", \"application/json\")\n\tif c.token != \"\" {\n\t\treq.Header.Set(\"Authorization\", \"Bearer \"+c.token)\n\t}\n\n\tresp, err := c.http.Do(req)\n\tif err != nil {\n\t\treturn err\n\t}\n\tdefer resp.Body.Close()\n\n\tif resp.StatusCode != http.StatusOK {\n\t\treturn fmt.Errorf(\"webview rpc status %d\", resp.StatusCode)\n\t}\n\n\tvar body enginewebview.RPCResponse\n\tif err := json.NewDecoder(resp.Body).Decode(&body); err != nil {\n\t\treturn err\n\t}\n\tif body.Error != nil {\n\t\treturn body.Error\n\t}\n\tif result == nil {\n\t\treturn nil\n\t}\n\tif len(body.Result) == 0 || string(body.Result) == \"null\" {\n\t\treturn nil\n\t}\n\treturn json.Unmarshal(body.Result, result)\n}\n","sourceCodeStart":160,"sourceCodeEnd":196,"githubUrl":"https://github.com/GopeedLab/gopeed/blob/7b7327ffb30816273a74b142cccc0bc10c5a4c67/internal/webview/rpcprovider/provider.go#L160-L196","documentation":"The rpcprovider drives a webview over a local HTTP JSON-RPC endpoint, authenticating with a bearer token. This error means the POST completed but returned a status other than 200; the response body is closed without decoding, so details are lost. The RPC layer distinguishes transport errors (returned raw) from HTTP-level failures (this message) from in-band errors (body.Error).","triggerScenarios":"401/403 when c.token is empty, stale, or rejected by the driver; 404 when the client's route does not match the driver version; 5xx when the driver process is crashing or out of resources. Any non-200 on the RPC endpoint.","commonSituations":"Driver and client version skew after an upgrade (route moved); token file regenerated but the client cached the old value; the webview driver process restarted or OOM-killed mid-session; port collision hitting a different local service.","solutions":["Check driver liveness first (process up, endpoint reachable)","For 401/403: re-provision or re-read the token so client and driver agree","For 404: align client and driver versions — a route mismatch usually means skew","For 5xx: restart the driver, check its logs and memory"],"exampleFix":"// before\nresp, err := c.call(ctx, method, params) // \"webview rpc status 404\" after upgrading the driver\n\n// after\n// re-sync endpoint + token from the driver, then retry once\nif isRPCStatus(err) {\n    c.RefreshEndpoint() // re-read base URL and token from driver state\n    resp, err = c.call(ctx, method, params)\n}","handlingStrategy":"retry","validationCode":"// Health-check the RPC endpoint before a session of calls\nfunc rpcHealthy(c *rpcClient, healthURL string) bool {\n    resp, err := c.http.Get(healthURL)\n    if err != nil {\n        return false\n    }\n    defer resp.Body.Close()\n    return resp.StatusCode == http.StatusOK\n}","typeGuard":null,"tryCatchPattern":"err := c.call(ctx, method, params)\nif err != nil && strings.Contains(err.Error(), \"webview rpc status \") {\n    var code int\n    fmt.Sscanf(err.Error(), \"webview rpc status %d\", &code)\n    switch {\n    case code == 401 || code == 403:\n        return c.reauthAndRetry(ctx, method, params) // refresh token, retry once\n    case code >= 500:\n        return retryWithBackoff(func() error { return c.call(ctx, method, params) }, 2)\n    }\n    return err // 404 etc: version/route skew, needs operator action\n}","preventionTips":["Re-read the token from the driver at session start instead of caching it across restarts","Pin client and driver to compatible versions; route moves signal skew","Monitor the driver process; 5xx usually precedes a crash visible in its logs"],"tags":["webview","rpc","http-status","auth","driver"],"backgroundTag":null,"analyzedSha":"7b7327ffb30816273a74b142cccc0bc10c5a4c67","analyzedAt":"2026-08-16T02:51:03.250Z","schemaVersion":2},"datasetVersion":"2026-08-16T03:17:38.424Z"}