{"record":{"id":"dfc9cd1816e7ac90","repo":"fish2018/pansou","slug":"api-200-d-dfc9cd","errorCode":null,"errorMessage":"API返回非200状态码: %d","messagePattern":"API返回非200状态码: (.+?)","errorType":"http","errorClass":null,"httpStatus":null,"severity":"error","filePath":"plugin/pan666/pan666.go","lineNumber":228,"sourceCode":"\t\t\tcontinue\n\t\t}\n\t\t\n\t\tdefer resp.Body.Close()\n\t\t\n\t\t// 读取响应体\n\t\tresponseBody, err = io.ReadAll(resp.Body)\n\t\tif err != nil {\n\t\t\tif i == p.retries {\n\t\t\t\treturn nil, false, fmt.Errorf(\"读取响应失败: %w\", err)\n\t\t\t}\n\t\t\ttime.Sleep(500 * time.Millisecond)\n\t\t\tcontinue\n\t\t}\n\t\t\n\t\t// 状态码检查\n\t\tif resp.StatusCode != http.StatusOK {\n\t\t\tif i == p.retries {\n\t\t\t\treturn nil, false, fmt.Errorf(\"API返回非200状态码: %d\", resp.StatusCode)\n\t\t\t}\n\t\t\ttime.Sleep(500 * time.Millisecond)\n\t\t\tcontinue\n\t\t}\n\t\t\n\t\t// 请求成功，跳出重试循环\n\t\tbreak\n\t}\n\t\n\t// 解析响应\n\tvar apiResp Pan666Response\n\tif err := json.Unmarshal(responseBody, &apiResp); err != nil {\n\t\treturn nil, false, fmt.Errorf(\"解析响应失败: %w\", err)\n\t}\n\t\n\t// 处理结果\n\tresults := make([]model.SearchResult, 0, len(apiResp.Data))\n\tpostMap := make(map[string]Pan666Post)","sourceCodeStart":210,"sourceCodeEnd":246,"githubUrl":"https://github.com/fish2018/pansou/blob/beaa56133755a548ebc51b090b3816e2ae044aa6/plugin/pan666/pan666.go#L210-L246","documentation":"pan666's fetchPage returns this when the server responds with a status code other than 200 on the final retry attempt. Earlier non-200 responses trigger a 500ms sleep and retry; once retries are exhausted the offending status code is reported. Note the response body — which may contain the API's error details — is discarded.","triggerScenarios":"client.Do succeeds and resp.StatusCode != http.StatusOK on all attempts: 403 (WAF/ban), 429 (rate limit), 500/502/503 (upstream fault), or 404 after an endpoint change.","commonSituations":"Rate limiting due to rapid searches; IP banned because of the randomized X-Forwarded-For/UA headers; pan666 API endpoint moved returning 404; origin server outage behind a gateway.","solutions":["Read a snippet of the response body before giving up — it usually names the block reason","Slow down request rate / add jitter if 429","Stop rotating X-Forwarded-For if the API bans on inconsistent forwarded IPs","Verify the BaseURL endpoint is still valid (404 case) and update it"],"exampleFix":"// before\nif resp.StatusCode != http.StatusOK {\n    if i == p.retries { return nil, false, fmt.Errorf(\"API返回非200状态码: %d\", resp.StatusCode) }\n// after\nif resp.StatusCode != http.StatusOK {\n    b, _ := io.ReadAll(io.LimitReader(resp.Body, 256))\n    if i == p.retries { return nil, false, fmt.Errorf(\"API返回非200状态码: %d body=%.256s\", resp.StatusCode, b) }","handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"if err != nil {\n    if strings.Contains(err.Error(), \"429\") {\n        select {\n        case <-time.After(rateLimitCooldown):\n        case <-ctx.Done():\n            return ctx.Err()\n        }\n        return retry()\n    }\n    return err\n}","preventionTips":["Back off significantly on 429 instead of fixed 500ms retries","Log response bodies of non-200 replies to learn block reasons","Keep request rate well below known API limits","Detect and stop using headers that trigger WAF bans (e.g. random X-Forwarded-For)"],"tags":["http","status-code","retry","plugin"],"backgroundTag":"http-non-200-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"}