fish2018/pansou · error

状态码

Error message

状态码: %d

What it means

Per-attempt status sentinel in yulinshufa doRequestWithRetry: the request returned a response but not 200, so this attempt is discarded (body closed) and lastErr is set to the code-only error; the loop retries with 200ms exponential backoff.

Solutions

  1. Map 403/429/5xx to pacing or header fixes
  2. Log the URL with the code for diagnosis
  3. Give up after retries and surface the last code
Defensive patterns

Strategy: retry

When it happens

Trigger: Thrown at plugin/yulinshufa/yulinshufa.go:748 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of fish2018/pansou@beaa561337 (2026-09-07). Data as JSON: /api/errors/b729ba60bb60264d. Report an issue: GitHub.

Appendix: source

Thrown at plugin/yulinshufa/yulinshufa.go:748

}

func (p *YulinshufaPlugin) doRequestWithRetry(client *http.Client, req *http.Request, maxRetries int) (*http.Response, error) {
	var lastErr error
	for attempt := 0; attempt < maxRetries; attempt++ {
		if attempt > 0 {
			backoff := time.Duration(1<<uint(attempt-1)) * 200 * time.Millisecond
			time.Sleep(backoff)
			p.debugf("重试第 %d 次, url=%s", attempt+1, req.URL.String())
		}

		resp, err := client.Do(req.Clone(req.Context()))
		if err == nil && resp.StatusCode == http.StatusOK {
			return resp, nil
		}

		if resp != nil {
			resp.Body.Close()
			lastErr = fmt.Errorf("状态码: %d", resp.StatusCode)
		} else {
			lastErr = err
		}
	}
	return nil, fmt.Errorf("请求重试 %d 次仍失败: %w", maxRetries, lastErr)
}

func parseDebugFlag() bool {
	value := strings.ToLower(strings.TrimSpace(os.Getenv("YULINSHUFA_DEBUG")))
	if value == "" {
		return false
	}
	return value == "1" || value == "true" || value == "yes" || value == "on"
}

func (p *YulinshufaPlugin) debugf(format string, args ...interface{}) {
	if p.debugMode {
		log.Printf("[YULINSHUFA] "+format, args...)

View on GitHub (pinned to beaa561337)