{"record":{"id":"c2a8205c3f67d36a","repo":"fish2018/pansou","slug":"s-w-c2a820","errorCode":null,"errorMessage":"[%s] 搜索第一页失败: %w","messagePattern":"\\[(.+?)\\] 搜索第一页失败: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"plugin/cldi/cldi.go","lineNumber":71,"sourceCode":"func (p *CldiPlugin) Search(keyword string, ext map[string]interface{}) ([]model.SearchResult, error) {\n\tresult, err := p.SearchWithResult(keyword, ext)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn result.Results, nil\n}\n\n// SearchWithResult 执行搜索并返回包含IsFinal标记的结果\nfunc (p *CldiPlugin) SearchWithResult(keyword string, ext map[string]interface{}) (model.PluginSearchResult, error) {\n\treturn p.AsyncSearchWithResult(keyword, p.searchImpl, p.MainCacheKey, ext)\n}\n\n// searchImpl 实际的搜索实现\nfunc (p *CldiPlugin) searchImpl(client *http.Client, keyword string, ext map[string]interface{}) ([]model.SearchResult, error) {\n\t// 1. 首先搜索第一页\n\tfirstPageResults, err := p.searchPage(client, keyword, 1)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"[%s] 搜索第一页失败: %w\", p.Name(), err)\n\t}\n\n\t// 存储所有结果\n\tvar allResults []model.SearchResult\n\tallResults = append(allResults, firstPageResults...)\n\n\t// 2. 并发搜索其他页面（第2页到第5页）\n\tif MaxPages > 1 {\n\t\tvar wg sync.WaitGroup\n\t\tvar mu sync.Mutex\n\n\t\t// 使用信号量控制并发数\n\t\tsemaphore := make(chan struct{}, MaxConcurrency)\n\n\t\t// 存储每页结果\n\t\tpageResults := make(map[int][]model.SearchResult)\n\n\t\tfor page := 2; page <= MaxPages; page++ {","sourceCodeStart":53,"sourceCodeEnd":89,"githubUrl":"https://github.com/fish2018/pansou/blob/beaa56133755a548ebc51b090b3816e2ae044aa6/plugin/cldi/cldi.go#L53-L89","documentation":"CldiPlugin.searchImpl wraps a failure from searchPage on page 1 with the plugin name for context. The wrapped error comes from request creation, request execution, status-code check, body read, or HTML parsing. It signals the initial search page could not be retrieved, so no results are returned.","triggerScenarios":"p.searchPage(client, keyword, 1) returns an error in searchImpl — e.g. the first page request timed out, was rate-limited, or its HTML couldn't be parsed.","commonSituations":"The CLDI site is down or blocking the client, network outage, or the search endpoint changed causing repeated failures.","solutions":["Inspect the wrapped cause (%w) to determine whether it was request creation, transport, status code, body read, or parsing.","Test the CLDI search URL manually with curl using the same headers.","Check for rate limiting or IP blocking; add backoff or proxy rotation.","Verify the endpoint URL and page-1 parameters are still valid."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"results, err := plugin.Search(ctx, keyword)\nif err != nil {\n    if strings.Contains(err.Error(), \"搜索第一页失败\") {\n        log.Printf(\"CLDI first page failed, skipping plugin: %v\", err)\n        // continue with other plugins' results\n    }\n}","preventionTips":["Treat per-plugin failures as non-fatal and aggregate results from other plugins","Monitor plugin-specific failure rates to detect blocked endpoints early","Keep plugin endpoint URLs and headers up to date","Add health checks per plugin before large batch searches"],"tags":["http","plugin","search","wrapper"],"backgroundTag":"api-request-failed","analyzedSha":"beaa56133755a548ebc51b090b3816e2ae044aa6","analyzedAt":"2026-09-07T00:31:18.025Z","contentChangedAt":"2026-09-07T00:31:18.025Z","schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}