fish2018/pansou · error

刷新Action ID失败

Error message

刷新Action ID失败: %w

What it means

When fetching search credentials with the current Action ID fails, doSearch attempts to re-discover (refresh) the Action IDs. If that refresh itself fails, the plugin gives up and wraps the discovery error as "刷新Action ID失败" — it cannot get credentials with either the old or refreshed IDs.

Solutions

  1. Inspect the wrapped discovery error (network vs parse) and address that root cause.
  2. Wait and retry with backoff — simultaneous failure of both paths often indicates transient outage or rate limiting.
  3. Update the discovery parsing logic if the upstream page structure changed.
  4. Check IP reputation / reduce request frequency if rate limited.
  5. Clear cached Action IDs and verify the discovery endpoint manually with curl.
Defensive patterns

Strategy: retry

Validate before calling

// Go (caller): probe the upstream endpoint before invoking search
resp, err := http.Head(upstreamBaseURL)
if err != nil || resp.StatusCode >= 400 {
    return nil, fmt.Errorf("panyq upstream unhealthy; skip search")
}

Try / catch

result, err := plugin.Search(keyword, ext)
if err != nil && strings.Contains(err.Error(), "刷新Action ID失败") {
    // both original and refreshed IDs failed; likely outage or rate limit
    time.Sleep(backoff)
    result, err = plugin.Search(keyword, ext)
    if err != nil { return err }
}

Prevention

When it happens

Trigger: getCredentials fails, then discoverActionIDs also errors: the discovery request fails at the transport level, the response structure changed so extraction fails, or anti-bot/rate limiting blocks the refresh request.

Common situations: Upstream rotated its page structure or API version; site temporarily down so both the original call and refresh fail; IP rate-limited after repeated failures; stale cached IDs expired AND discovery blocked.

Related errors


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

Appendix: source

Thrown at plugin/panyq/panyq.go:217

func (p *PanyqPlugin) doSearch(client *http.Client, keyword string, ext map[string]interface{}) ([]model.SearchResult, error) {
	if DebugLog {
		fmt.Println("panyq: searching for", keyword)
	}

	// 尝试获取或发现 Action ID
	actionIDs, err := p.getOrDiscoverActionIDs()
	if err != nil {
		// fmt.Println("panyq: failed to get Action IDs:", err)
		return nil, fmt.Errorf("获取Action ID失败: %w", err)
	}

	// 步骤1: 获取搜索凭证
	credentials, err := p.getCredentials(keyword, actionIDs[ActionIDKeys[0]], client)
	if err != nil {
		// 如果获取凭证失败,尝试刷新Action ID并重试
		actionIDs, err = p.discoverActionIDs()
		if err != nil {
			return nil, fmt.Errorf("刷新Action ID失败: %w", err)
		}
		
		// 使用新的Action ID重试获取凭证
		credentials, err = p.getCredentials(keyword, actionIDs[ActionIDKeys[0]], client)
		if err != nil {
			return nil, fmt.Errorf("获取搜索凭证失败: %w", err)
		}
	}

	// 步骤2: 获取第一页搜索结果列表
	hits, maxPageNum, err := p.getSearchResults(credentials.Sign, 1, client)
	if err != nil {
		return nil, fmt.Errorf("获取搜索结果失败: %w", err)
	}

	if len(hits) == 0 {
		if DebugLog {
			fmt.Println("panyq: no results found for", keyword)

View on GitHub (pinned to beaa561337)