{"record":{"id":"abb9dac54192b57d","repo":"fish2018/pansou","slug":"d-abb9da","errorCode":null,"errorMessage":"状态码 %d","messagePattern":"状态码 %d","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"plugin/dy4k/dy4k.go","lineNumber":1056,"sourceCode":"\t\t\treturn resp, nil\n\t\t}\n\n\t\tdebugPrintf(\"❌ [Dy4k DEBUG] 第 %d 次尝试状态码异常: %d\\n\", i+1, resp.StatusCode)\n\n\t\t// 读取响应体以便调试\n\t\tif resp.Body != nil {\n\t\t\tbodyBytes, readErr := io.ReadAll(resp.Body)\n\t\t\tresp.Body.Close()\n\t\t\tif readErr == nil && len(bodyBytes) > 0 {\n\t\t\t\tbodyPreview := string(bodyBytes)\n\t\t\t\tif len(bodyPreview) > 200 {\n\t\t\t\t\tbodyPreview = bodyPreview[:200] + \"...\"\n\t\t\t\t}\n\t\t\t\tdebugPrintf(\"🔧 [Dy4k DEBUG] 响应体预览: %s\\n\", bodyPreview)\n\t\t\t}\n\t\t}\n\n\t\tlastErr = fmt.Errorf(\"状态码 %d\", resp.StatusCode)\n\t}\n\n\tdebugPrintf(\"❌ [Dy4k DEBUG] 所有重试都失败了!\\n\")\n\treturn nil, fmt.Errorf(\"重试 %d 次后仍然失败: %w\", maxRetries, lastErr)\n}\n\n// getRandomUA 获取随机User-Agent\nfunc getRandomUA() string {\n\tuserAgents := []string{\n\t\t\"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/119.0.0.0 Safari/537.36\",\n\t\t\"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/118.0.0.0 Safari/537.36\",\n\t\t\"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/119.0.0.0 Safari/537.36\",\n\t\t\"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/17.1 Safari/605.1.15\",\n\t\t\"Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:109.0) Gecko/20100101 Firefox/119.0\",\n\t\t\"Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/119.0.0.0 Safari/537.36\",\n\t\t\"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/119.0.0.0 Safari/537.36 Edg/119.0.0.0\",\n\t\t\"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/118.0.0.0 Safari/537.36\",\n\t}","sourceCodeStart":1038,"sourceCodeEnd":1074,"githubUrl":"https://github.com/fish2018/pansou/blob/beaa56133755a548ebc51b090b3816e2ae044aa6/plugin/dy4k/dy4k.go#L1038-L1074","documentation":"This internal error is produced by Dy4kPlugin.doRequestWithRetry when the server responds with a non-acceptable HTTP status code; the status code is recorded as lastErr. It is not returned directly — after all retries are exhausted it is wrapped by error 123. It means the 4KDY site repeatedly answered with an error status (403, 429, 5xx, etc.) across every retry attempt.","triggerScenarios":"searchPage -> doRequestWithRetry when every attempt receives a rejected status code (e.g., 403 blocked, 429 rate-limited, 500/502 server error) and the response status check fails on all retries.","commonSituations":"IP is blocked or rate-limited by the site's anti-scraping defenses; User-Agent flagged; site temporarily down (5xx); geo-blocking; expired domain serving error pages.","solutions":["Check the debug log's response body preview to identify which status and page the server returned","Back off and retry later if the status is 429 (rate limiting)","Rotate the User-Agent (getRandomUA) or route through a different IP/proxy if 403","Verify the site is up and the domain hasn't changed (5xx / NXIO cases)"],"exampleFix":"// before\nlastErr = fmt.Errorf(\"状态码 %d\", resp.StatusCode)\n// after\nlastErr = fmt.Errorf(\"状态码 %d\", resp.StatusCode)\nif resp.StatusCode == http.StatusTooManyRequests {\n    time.Sleep(backoff) // honor rate limiting before next retry\n}","handlingStrategy":"retry","validationCode":"resp, err := client.Get(probeURL)\nif err == nil && resp.StatusCode == http.StatusOK { /* site reachable, proceed */ }","typeGuard":null,"tryCatchPattern":"body, err := doRequestWithRetry(client, url)\nif err != nil {\n    if strings.Contains(err.Error(), \"状态码 429\") {\n        time.Sleep(rateLimitBackoff) // honor rate limiting\n    }\n    return err\n}","preventionTips":["Throttle request rate to stay under the site's limits","Rotate User-Agent and IPs when scraping protected sites","Use exponential backoff between retries","Watch debug logs for status codes and body previews to react early"],"tags":["http","status-code","retry","anti-bot"],"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"}