fish2018/pansou · error

[ ] 网盘第 页API错误

Error message

[%s] %s网盘第%d页API错误: %s

What it means

The HTTP response was valid JSON, but the API's business-logic status field (APIResponse.Code) is not 200. The API itself reported an application-level error, whose human-readable message is included in the error (APIResponse.Msg).

Solutions

  1. Read the Msg embedded in the error — it usually states the server-side reason directly.
  2. For rate-limit-style messages, reduce request frequency and add backoff between page requests.
  3. For parameter errors, verify keyword/fromType/pageNo against the current API contract and update the plugin.
  4. Treat persistent code!=200 responses as a site-contract change: re-check the sdso.top frontend for API updates.
  5. Fall back to other search plugins in the aggregator for this keyword.

Example fix

// before
if apiResp.Code != 200 {
    return nil, fmt.Errorf("API错误: %s", apiResp.Msg)
}
// after
if apiResp.Code == 429 {
    time.Sleep(2 * time.Second)
    return p.fetchSinglePageWithType(client, keyword, pageNo, fromType) // retry once
}
if apiResp.Code != 200 {
    return nil, fmt.Errorf("API错误: %s", apiResp.Msg)
}
Defensive patterns

Strategy: try-catch

Try / catch

results, err := plugin.Search(ctx, keyword)
if err != nil && strings.Contains(err.Error(), "API错误") {
    // server-reported business error; log Msg and degrade gracefully
    log.Printf("sdso API rejected the search: %v", err)
}

Prevention

When it happens

Trigger: sdso.top /api/sd/search responds with JSON where code != 200 — e.g. invalid parameters, search keyword rejected, rate limiting enforced at the application layer, account/quota errors, or an upstream failure reported inside the JSON envelope.

Common situations: Application-level rate limiting after heavy scraping; the API requiring new mandatory parameters after a site update; keyword rejected by server-side validation; the site's backend database/service being down while the gateway still returns JSON errors.

Related errors


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

Appendix: source

Thrown at plugin/sdso/sdso.go:268

	if err != nil {
		return nil, fmt.Errorf("[%s] %s网盘第%d页请求失败: %w", p.Name(), fromType, pageNo, err)
	}
	defer resp.Body.Close()

	// 6. 检查状态码
	if resp.StatusCode != 200 {
		return nil, fmt.Errorf("[%s] %s网盘第%d页返回状态码: %d", p.Name(), fromType, pageNo, resp.StatusCode)
	}

	// 7. 解析响应
	var apiResp APIResponse
	if err := json.NewDecoder(resp.Body).Decode(&apiResp); err != nil {
		return nil, fmt.Errorf("[%s] %s网盘第%d页JSON解析失败: %w", p.Name(), fromType, pageNo, err)
	}

	// 8. 检查API响应状态
	if apiResp.Code != 200 {
		return nil, fmt.Errorf("[%s] %s网盘第%d页API错误: %s", p.Name(), fromType, pageNo, apiResp.Msg)
	}

	if DebugLog {
		fmt.Printf("[%s] %s网盘第%d页获取到 %d 个原始结果\n", p.Name(), fromType, pageNo, len(apiResp.Data.List))
	}

	// 9. 转换为标准格式
	results := make([]model.SearchResult, 0, len(apiResp.Data.List))
	processedCount := 0
	skippedCount := 0
	
	for i, item := range apiResp.Data.List {
		// 解密网盘链接
		decryptedURL, err := DecryptURL(item.URL)
		if err != nil {
			if DebugLog {
				fmt.Printf("[%s] %s网盘第%d页第%d项解密失败: %v\n", p.Name(), fromType, pageNo, i+1, err)
			}

View on GitHub (pinned to beaa561337)