fish2018/pansou · error

[ ] 执行搜索失败

Error message

[%s] 执行搜索失败: %w

What it means

searchImpl in the javdb plugin wraps any non-rate-limited failure from executeSearchWithRateLimit as '[javdb] 执行搜索失败: %w' (search execution failed). It is the top-level error aggregator for the search step; rate-limited runs (isRateLimited=true) are deliberately not wrapped because partial results are still processed.

Solutions

  1. Unwrap the %w cause to find which inner step failed
  2. Curl the javdb search URL with the same headers to check reachability/blocking
  3. Verify the search URL and User-Agent still match the current site behavior
  4. Increase the client timeout if failures correlate with slow responses
  5. Treat this error in callers as 'source temporarily unavailable' and fall back to other plugins
Defensive patterns

Strategy: try-catch

Validate before calling

// Go: check source reachability before invoking search
resp, err := http.Head("https://javdb.com")
if err != nil || resp.StatusCode >= 400 {
    log.Printf("javdb unreachable, skipping")
}

Type guard

func isSearchExecFailure(err error) bool {
    return err != nil && strings.Contains(err.Error(), "执行搜索失败")
}

Try / catch

results, err := p.searchImpl(client, keyword)
if err != nil {
    var inner error = errors.Unwrap(err)
    log.Printf("javdb search failed (cause=%v): %v", inner, err)
    return nil, err
}

Prevention

When it happens

Trigger: executeSearchWithRateLimit returns an error with isRateLimited=false — e.g. request creation failure, client.Do transport error, non-200 status, body read failure, or HTML parse failure.

Common situations: javdb blocks or changes its endpoint; network egress blocked in the container; HTTP client timeout too short; site returns 5xx or a bot-block page; goquery fails on an unexpected response.

Understand the failure class

Background: "API request failed": what wrapped HTTP errors from external APIs mean and how to find the real cause — this error's family across 29 libraries.

Related errors


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

Appendix: source

Thrown at plugin/javdb/javdb.go:117

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

// searchImpl 搜索实现
func (p *JavdbPlugin) searchImpl(client *http.Client, keyword string, ext map[string]interface{}) ([]model.SearchResult, error) {
	if p.debugMode {
		log.Printf("[JAVDB] 开始搜索: %s", keyword)
	}

	if p.debugMode {
		log.Printf("[JAVDB] 开始搜索,客户端超时: %v", client.Timeout)
	}

	// 第一步:执行搜索获取结果列表
	searchResults, err, isRateLimited := p.executeSearchWithRateLimit(client, keyword)
	if err != nil && !isRateLimited {
		return nil, fmt.Errorf("[%s] 执行搜索失败: %w", p.Name(), err)
	}

	if p.debugMode {
		if isRateLimited {
			log.Printf("[JAVDB] ⚡ 遇到429限流,但继续处理已获取的 %d 个结果", len(searchResults))
		} else {
			log.Printf("[JAVDB] 搜索获取到 %d 个结果", len(searchResults))
		}
	}

	// 如果没有搜索结果,直接返回
	if len(searchResults) == 0 {
		if p.debugMode {
			log.Printf("[JAVDB] 无搜索结果,直接返回")
		}
		return []model.SearchResult{}, nil
	}

View on GitHub (pinned to beaa561337)