{"record":{"id":"db07051949f68b4f","repo":"fish2018/pansou","slug":"api-200-d","errorCode":null,"errorMessage":"API返回非200状态码: %d","messagePattern":"API返回非200状态码: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"plugin/bixin/bixin.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 BixinResponse\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]BixinPost)","sourceCodeStart":210,"sourceCodeEnd":246,"githubUrl":"https://github.com/fish2018/pansou/blob/beaa56133755a548ebc51b090b3816e2ae044aa6/plugin/bixin/bixin.go#L210-L246","documentation":"fetchPage in the bixin plugin returns this when the API responds with a status code other than 200 after all retry attempts are exhausted. It is an upstream API-level failure (e.g. 403 anti-bot block, 404, 429 rate limit, 5xx) rather than a transport error. Only the numeric code is reported, not the body, which limits diagnostics.","triggerScenarios":"resp.StatusCode != http.StatusOK on the final retry iteration (i == p.retries) in fetchPage — e.g. repeated 429 rate limiting or a 403 from the WAF.","commonSituations":"Rate limiting due to too-frequent scraping, IP banned by the site's anti-bot protection, endpoint path changed upstream, or server outage.","solutions":["Log resp.StatusCode and read a snippet of the body before returning to identify 403/429/5xx causes.","If 429: reduce request frequency or honor Retry-After; add exponential backoff.","If 403: update request headers (User-Agent, cookies, tokens) to match what the site expects.","Verify the bixin API endpoint URL is still current."],"exampleFix":"// before\nreturn nil, false, fmt.Errorf(\"API返回非200状态码: %d\", resp.StatusCode)\n// after\nbodySnippet, _ := io.ReadAll(io.LimitReader(resp.Body, 512))\nreturn nil, false, fmt.Errorf(\"API返回非200状态码: %d, body: %s\", resp.StatusCode, bodySnippet)","handlingStrategy":"fallback","validationCode":"// probe the endpoint's health before running a search batch\nresp, err := http.Get(baseURL)\nif err != nil || resp.StatusCode != http.StatusOK {\n    log.Printf(\"bixin API unhealthy (status=%v)\", err)\n}\nif resp != nil { resp.Body.Close() }","typeGuard":null,"tryCatchPattern":"results, err := plugin.Search(ctx, keyword)\nif err != nil {\n    if strings.Contains(err.Error(), \"非200状态码\") {\n        // extract status code, apply rate-limit/backoff or switch to fallback source\n    }\n}","preventionTips":["Throttle request rate to avoid 429s","Keep User-Agent/cookies/headers current to dodge WAF blocks","Log status code and body snippet on every non-200 for diagnosis","Monitor the upstream endpoint for outages and schema changes"],"tags":["http","api","status-code","upstream"],"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"}