fish2018/pansou · error

[susu] 获取按钮详情失败

Error message

[susu] 获取按钮详情失败: %w

What it means

Terminal wrapper in susu getButtonDetail: doRequestWithRetry exhausted MaxRetries attempts for the button-detail POST. The cause is the last transport error or non-200 status seen during those attempts.

Solutions

  1. Inspect the wrapped cause (transport vs status)
  2. Slow down retries — this endpoint is rate-limit sensitive
  3. Cache negative results briefly to avoid hammering on repeated failures
Defensive patterns

Strategy: retry

When it happens

Trigger: Thrown at plugin/susu/susu.go:455 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/38f71d297b6370b6. Report an issue: GitHub.

Appendix: source

Thrown at plugin/susu/susu.go:455

	form := url.Values{
		"post_id": {postID},
		"index":   {fmt.Sprintf("%d", index)},
		"i":       {fmt.Sprintf("%d", i)},
		"guest":   {""},
	}
	ctx, cancel := context.WithTimeout(context.Background(), 20*time.Second)
	defer cancel()

	req, err := http.NewRequestWithContext(ctx, http.MethodPost, ButtonDetailURL, strings.NewReader(form.Encode()))
	if err != nil {
		return model.Link{}, fmt.Errorf("[susu] 创建按钮详情请求失败: %w", err)
	}
	setAPIHeaders(req, fmt.Sprintf("%s/download?post_id=%s&index=%d&i=%d", BaseURL, postID, index, i))

	// 发送请求(带重试)
	resp, err := p.doRequestWithRetry(client, req, MaxRetries)
	if err != nil {
		return model.Link{}, fmt.Errorf("[susu] 获取按钮详情失败: %w", err)
	}
	defer resp.Body.Close()
	if resp.StatusCode != http.StatusOK {
		return model.Link{}, fmt.Errorf("[susu] 按钮详情请求返回状态码: %d", resp.StatusCode)
	}

	// 读取响应体
	respBody, err := io.ReadAll(io.LimitReader(resp.Body, 2<<20))
	if err != nil {
		return model.Link{}, fmt.Errorf("[susu] 读取按钮详情失败: %w", err)
	}

	// 解析响应
	var buttonDetail buttonDetailResponse
	if err := json.Unmarshal(respBody, &buttonDetail); err != nil {
		return model.Link{}, fmt.Errorf("[susu] 解析按钮详情失败: %w", err)
	}

View on GitHub (pinned to beaa561337)