fish2018/pansou · error

[susu] 按钮URL为空

Error message

[susu] 按钮URL为空

What it means

Empty-response guard: the susu button-detail API returned a decodable JSON payload whose Button.URL field is empty. The endpoint is up but declined to hand out a link for this post_id/index/i (expired, invalid, or not-yet-generated token).

Solutions

  1. Treat as a permanent per-button failure: skip this link, don't retry immediately
  2. Refresh the parent post/page to obtain fresh button indices
  3. Check for account/session requirements on the endpoint
Defensive patterns

Strategy: validation

When it happens

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

Appendix: source

Thrown at plugin/susu/susu.go:476

	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)
	}

	// 如果URL为空
	if buttonDetail.Button.URL == "" {
		return model.Link{}, fmt.Errorf("[susu] 按钮URL为空")
	}

	// 解析JWT token获取真实链接
	realURL, err := p.decodeJWTURL(buttonDetail.Button.URL)
	if err != nil {
		return model.Link{}, fmt.Errorf("[susu] 解析JWT失败: %w", err)
	}
	realURL = strings.TrimSpace(realURL)
	parsedURL, err := url.Parse(realURL)
	if err != nil || (parsedURL.Scheme != "http" && parsedURL.Scheme != "https") || parsedURL.Host == "" {
		return model.Link{}, fmt.Errorf("[susu] 按钮返回无效链接")
	}

	// 创建链接
	link := model.Link{
		URL:      realURL,
		Type:     p.determineLinkType(realURL, buttonDetail.Button.Name),
		Password: extractPassword(realURL, buttonDetail.Button.Attr.TQ),

View on GitHub (pinned to beaa561337)