fish2018/pansou · error

获取Action ID失败

Error message

获取Action ID失败: %w

What it means

doSearch first obtains the site's Action IDs (obfuscated parameter identifiers scraped/discovered from the upstream API page) via getOrDiscoverActionIDs. If neither the cached nor a fresh discovery succeeds, it wraps the underlying error as "获取Action ID失败" — the plugin cannot construct valid search requests without these IDs.

Solutions

  1. Inspect the wrapped error to see whether it was a network failure or a parse failure.
  2. Check whether the upstream page structure changed and update the discovery regex/parser.
  3. Clear any stale cache so discovery is retried cleanly.
  4. Add retry with backoff for transient discovery failures.
  5. Verify reachability of the discovery endpoint (curl it and compare against the parser expectations).
Defensive patterns

Strategy: retry

Validate before calling

// Go (caller): health-check the plugin's upstream before searching
ids, err := plugin.GetOrDiscoverActionIDs() // if exported; otherwise probe the site URL
if err != nil {
    return nil, fmt.Errorf("panyq upstream unavailable: %w", err)
}

Try / catch

result, err := plugin.Search(keyword, ext)
if err != nil && strings.Contains(err.Error(), "获取Action ID失败") {
    // upstream structure changed or discovery request failed; retry later or alert
    log.Printf("panyq action-id discovery failed: %v", err)
    return err
}

Prevention

When it happens

Trigger: getOrDiscoverActionIDs returns an error: cached IDs absent and discoverActionIDs fails because the upstream page is unreachable, its HTML structure changed so the regex/parser no longer matches, or the request was blocked (403/captcha).

Common situations: Upstream site updated its frontend so Action ID extraction breaks; network/anti-bot blocking the discovery request; first-run with empty cache during an outage; version drift where the site rotates IDs.

Related errors


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

Appendix: source

Thrown at plugin/panyq/panyq.go:208

	return results, err
}

// SearchWithResult 执行搜索并返回包含IsFinal标记的结果
func (p *PanyqPlugin) SearchWithResult(keyword string, ext map[string]interface{}) (model.PluginSearchResult, error) {
	return p.AsyncSearchWithResult(keyword, p.doSearch, p.MainCacheKey, ext)
}

// doSearch 实际的搜索实现
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)
		}
	}

View on GitHub (pinned to beaa561337)