fish2018/pansou · warning

API error

Error message

%s API error: %w

What it means

In the Sousou plugin, each disk type (e.g. 百度网盘, 阿里云盘) is searched concurrently in a goroutine. When searchByType fails for one type, the error is wrapped as '<diskType> API error: %w' and sent to errChan for aggregation; the overall search may still succeed using other types' results. This is a per-source-type failure record.

Solutions

  1. Check errChan entries to see which disk type failed and its underlying cause.
  2. Retry only the failing disk type after backoff; treat partial success as acceptable.
  3. Verify selectors/URL for that specific pan type — upstream layout may have changed.
  4. Add per-type timeout and rate limiting to avoid hammering one provider.

Example fix

// before
errChan <- fmt.Errorf("%s API error: %w", dt, err)
// after
debugLog("%s 网盘搜索错误: %v", dt, err)
errChan <- fmt.Errorf("%s API error: %w", dt, err) // collect; fail only if ALL types fail
Defensive patterns

Strategy: try-catch

Try / catch

results, err := plugin.Search(keyword)
if err != nil {
    // aggregate: check whether ANY disk type succeeded; log per-type failures
    // partial success from other types is often acceptable
}

Prevention

When it happens

Trigger: searchByType(client, keyword, diskType) returns an error inside the per-disk-type goroutine spawned by the plugin's search fan-out; the wrapped error is pushed onto errChan.

Common situations: One specific pan provider changed its page structure or is rate-limiting, while other types still return results; keyword triggers a upstream 4xx.

Related errors


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

Appendix: source

Thrown at plugin/sousou/sousou.go:110

	// 创建结果通道和错误通道
	resultChan := make(chan []SousouItem, len(supportedDiskTypes))
	errChan := make(chan error, len(supportedDiskTypes))

	// 创建等待组
	var wg sync.WaitGroup

	// 并发搜索每种网盘类型
	for _, diskType := range supportedDiskTypes {
		wg.Add(1)

		go func(dt string) {
			defer wg.Done()
			debugLog("开始搜索网盘类型: %s", dt)

			items, err := p.searchByType(client, keyword, dt)
			if err != nil {
				debugLog("%s 网盘搜索错误: %v", dt, err)
				errChan <- fmt.Errorf("%s API error: %w", dt, err)
				return
			}

			debugLog("%s 网盘返回 %d 条结果", dt, len(items))
			resultChan <- items
		}(diskType)
	}

	// 启动一个goroutine等待所有请求完成并关闭通道
	go func() {
		wg.Wait()
		close(resultChan)
		close(errChan)
	}()

	// 收集结果
	var allItems []SousouItem
	var errors []error

View on GitHub (pinned to beaa561337)