{"record":{"id":"c44ed628d4e43c8c","repo":"fish2018/pansou","slug":"http-403-forbidden-c44ed6","errorCode":null,"errorMessage":"HTTP 403 Forbidden","messagePattern":"HTTP 403 Forbidden","errorType":"exception","errorClass":null,"httpStatus":403,"severity":"error","filePath":"plugin/gying/gying.go","lineNumber":2718,"sourceCode":"\t// 使用cloudscraper发送请求（自动管理Cookie和绕过反爬虫）\n\tbody, statusCode, _, err := p.requestWithChallengeRetry(scraper, http.MethodGet, detailURL, \"\", \"\")\n\tif err != nil {\n\t\tif DebugLog {\n\t\t\tfmt.Printf(\"[Gying]     请求失败: %v\\n\", err)\n\t\t}\n\t\treturn nil, err\n\t}\n\n\tif DebugLog {\n\t\tfmt.Printf(\"[Gying]     响应状态码: %d\\n\", statusCode)\n\t}\n\n\t// 检查403错误\n\tif statusCode == http.StatusForbidden {\n\t\tif DebugLog {\n\t\t\tfmt.Printf(\"[Gying]     ❌ 详情接口返回403 - Cookie可能已过期\\n\")\n\t\t}\n\t\treturn nil, fmt.Errorf(\"HTTP 403 Forbidden\")\n\t}\n\n\tif statusCode != http.StatusOK {\n\t\tif DebugLog {\n\t\t\tfmt.Printf(\"[Gying]     ❌ HTTP错误: %d\\n\", statusCode)\n\t\t}\n\t\treturn nil, fmt.Errorf(\"HTTP %d\", statusCode)\n\t}\n\n\tif DebugLog {\n\t\tfmt.Printf(\"[Gying]     响应长度: %d 字节\\n\", len(body))\n\t}\n\tif isLoginShell(body) {\n\t\treturn nil, fmt.Errorf(\"HTTP 403 Forbidden\")\n\t}\n\n\tvar detail DetailData\n\tif err := json.Unmarshal(body, &detail); err != nil {","sourceCodeStart":2700,"sourceCodeEnd":2736,"githubUrl":"https://github.com/fish2018/pansou/blob/beaa56133755a548ebc51b090b3816e2ae044aa6/plugin/gying/gying.go#L2700-L2736","documentation":"fetchDetail in the Gying plugin calls the site's /res/downurl detail endpoint through a cloudscraper session and throws this error when the HTTP response status is exactly 403. The plugin interprets 403 as an expired or invalid session cookie (or an unresolved anti-bot challenge), so the caller is expected to re-login and retry.","triggerScenarios":"Calling fetchDetail (via fetchAllDetails during Search) when the site returns HTTP 403: the stored cookie/session has expired, the Cloudflare-style challenge was not solved, or the server is blocking the client IP/User-Agent.","commonSituations":"Long-running deployments where the site session rotted overnight; running from a datacenter IP that the site rate-limits or blocks; cloudscraper failing to pass the anti-bot challenge; the site changing its login/challenge flow.","solutions":["Re-run the plugin login flow to refresh the session cookie, then retry the search.","Enable DebugLog and inspect the response to see whether it is a challenge page or an auth rejection.","If it persists, check whether the server blocks your IP; route through a different egress or add delay between requests.","Update the plugin/site config (base URL, headers) if the site changed its anti-bot scheme."],"exampleFix":"// before\nresults, err := plugin.Search(ctx, query) // fails with HTTP 403 Forbidden\n// after\nif err != nil && strings.Contains(err.Error(), \"403\") {\n    if rerr := plugin.Relogin(ctx); rerr != nil { return rerr }\n    results, err = plugin.Search(ctx, query)\n}","handlingStrategy":"retry","validationCode":"// re-login if session is stale before searching\nif time.Since(lastLogin) > sessionTTL {\n    if err := plugin.Relogin(ctx); err != nil { return err }\n}","typeGuard":"func isForbidden(err error) bool { return err != nil && strings.Contains(err.Error(), \"403\") }","tryCatchPattern":"results, err := plugin.Search(ctx, kw)\nif isForbidden(err) {\n    if rerr := plugin.Relogin(ctx); rerr != nil { return rerr }\n    results, err = plugin.Search(ctx, kw)\n}","preventionTips":["Refresh the site session cookie on a schedule shorter than its TTL.","Keep request rates low to avoid IP-level blocking.","Route detail fetches through the same logged-in cloudscraper session.","Alert on repeated 403s to detect account/IP bans early."],"tags":["http","auth","session-expired","network"],"backgroundTag":"http-error-response","analyzedSha":"beaa56133755a548ebc51b090b3816e2ae044aa6","analyzedAt":"2026-09-07T00:31:18.025Z","contentChangedAt":"2026-09-07T00:31:18.025Z","schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}