fish2018/pansou · error
HTTP状态码
Error message
HTTP状态码: %d
What it means
Internal error created by doRequestWithRetry when the server responded but with a non-200 status code. The response body is closed and the status is recorded as lastErr; if all retries fail with status errors, this becomes the wrapped cause of error 475. It is a sentinel describing the HTTP status, not a full error type.
Solutions
- Capture and log a portion of the response body before closing it to learn why the status was non-200
- Back off and retry later if the status is 429 (rate limited)
- Rotate IP / use a proxy if 403 WAF blocks persist
- Check whether the base URL https://woog.nxog.eu.org/ is still the correct endpoint
Example fix
// before
resp.Body.Close()
lastErr = fmt.Errorf("HTTP状态码: %d", resp.StatusCode)
// after
snippet, _ := io.ReadAll(io.LimitReader(resp.Body, 256))
resp.Body.Close()
lastErr = fmt.Errorf("HTTP状态码: %d, body=%.256s", resp.StatusCode, snippet) Defensive patterns
Strategy: retry
Try / catch
if err != nil && strings.Contains(err.Error(), "HTTP状态码: 429") {
time.Sleep(time.Duration(jitter(2, 10)) * time.Second)
return retry()
} Prevention
- Throttle request rate to stay under the API's limits
- Preserve the response body of failed statuses for diagnosis
- Treat 5xx and 4xx differently: back off long on 429/403
- Rotate proxies if WAF blocks persist
When it happens
Trigger: client.Do succeeds and resp.StatusCode != http.StatusOK on every retry attempt (e.g. 403, 429, 500, 502 from woog.nxog.eu.org); only the numeric status is kept, discarding the response body that may contain the real reason.
Common situations: IP rate-limited (429) by the API; Cloudflare/WAF challenge (403); upstream origin down behind a proxy (502/503); the site moved and old host returns 404.
Related errors
AI-assisted analysis of fish2018/pansou@beaa561337 (2026-09-07).
Data as JSON: /api/errors/aad36eaab78009b3.
Report an issue: GitHub.
Appendix: source
Thrown at plugin/ouge/ouge.go:412
if len(matches) > 1 {
return matches[1]
}
return ""
}
// doRequestWithRetry 带重试的HTTP请求(优化JSON API的重试策略)
func (p *OugeAsyncPlugin) doRequestWithRetry(req *http.Request, client *http.Client) (*http.Response, error) {
maxRetries := 2 // 对于JSON API减少重试次数
var lastErr error
for i := 0; i < maxRetries; i++ {
resp, err := client.Do(req)
if err == nil {
if resp.StatusCode == http.StatusOK {
return resp, nil
}
resp.Body.Close()
lastErr = fmt.Errorf("HTTP状态码: %d", resp.StatusCode)
} else {
lastErr = err
}
// JSON API快速重试:只等待很短时间
if i < maxRetries-1 {
time.Sleep(100 * time.Millisecond) // 从秒级改为100毫秒
}
}
return nil, fmt.Errorf("[%s] 请求失败,重试%d次后仍失败: %w", p.Name(), maxRetries, lastErr)
}
// GetPerformanceStats 获取性能统计信息
func (p *OugeAsyncPlugin) GetPerformanceStats() map[string]interface{} {
totalRequests := atomic.LoadInt64(&searchRequests)
totalTime := atomic.LoadInt64(&totalSearchTime)
View on GitHub (pinned to beaa561337)