{"record":{"id":"689bfcef34e4905b","repo":"fish2018/pansou","slug":"http-d","errorCode":null,"errorMessage":"HTTP错误状态码: %d","messagePattern":"HTTP错误状态码: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"plugin/cyg/cyg.go","lineNumber":155,"sourceCode":"\t// 创建请求对象\n\treq, err := http.NewRequestWithContext(ctx, \"GET\", searchURL, nil)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"创建请求失败: %w\", err)\n\t}\n\n\t// 设置请求头\n\tp.setRequestHeaders(req)\n\n\t// 发送请求\n\tresp, err := p.doRequestWithRetry(req, client)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"HTTP请求失败: %w\", err)\n\t}\n\tdefer resp.Body.Close()\n\n\t// 检查状态码\n\tif resp.StatusCode != 200 {\n\t\treturn nil, fmt.Errorf(\"HTTP错误状态码: %d\", resp.StatusCode)\n\t}\n\n\t// 解析响应\n\tbody, err := io.ReadAll(resp.Body)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"读取响应失败: %w\", err)\n\t}\n\n\tvar posts []CygPost\n\tif err := json.Unmarshal(body, &posts); err != nil {\n\t\treturn nil, fmt.Errorf(\"JSON解析失败: %w\", err)\n\t}\n\n\treturn posts, nil\n}\n\n// fetchDownloadLinksAsync 并发获取下载链接\nfunc (p *CygPlugin) fetchDownloadLinksAsync(client *http.Client, posts []CygPost, keyword string) []model.SearchResult {","sourceCodeStart":137,"sourceCodeEnd":173,"githubUrl":"https://github.com/fish2018/pansou/blob/beaa56133755a548ebc51b090b3816e2ae044aa6/plugin/cyg/cyg.go#L137-L173","documentation":"fetchSearchResults requires the WordPress REST endpoint to return HTTP 200; any other status aborts with this error carrying the actual code. It indicates the search request reached the server but was rejected or the server errored.","triggerScenarios":"searchImpl's request completes but the /wp-json/wp/v2/posts endpoint returns non-200: 400 (bad per_page/page params), 403/401 (blocked or protected REST API), 404 (REST API disabled/removed), 429 or 5xx.","commonSituations":"Site disabled the REST API via plugin/security config; WAF blocks the client's User-Agent; requesting a page number beyond available results with some server configs returning 400; upstream outage.","solutions":["Log the status code and response body snippet to identify why the server rejected the request.","Set a browser-like User-Agent and other headers (setRequestHeaders) to pass WAF checks.","Clamp/validate opts.Page and opts.PerPage to ranges the server accepts (e.g. per_page ≤ 100).","Confirm the REST API is enabled on the target WordPress site (visit /wp-json/wp/v2/posts directly)."],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"results, err := plugin.SearchWithResult(ctx, opts)\nif err != nil && strings.Contains(err.Error(), \"HTTP错误状态码\") {\n    var sc int\n    fmt.Sscanf(err.Error(), \"HTTP错误状态码: %d\", &sc)\n    if sc == 429 || sc >= 500 {\n        // transient: retry with backoff; 4xx: fix params/headers instead\n    }\n}","preventionTips":["Keep per_page within WordPress limits (≤100) and page numbers valid","Send a browser-like User-Agent to avoid WAF blocks","Confirm the target site has the REST API enabled before integrating","Back off on 429/5xx rather than hammering retries"],"tags":["http","status-code","wordpress","go"],"backgroundTag":"http-error-status","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"}