{"record":{"id":"39fdcc6115c65130","repo":"fish2018/pansou","slug":"s-w-39fdcc","errorCode":null,"errorMessage":"[%s] 搜索请求失败: %w","messagePattern":"\\[(.+?)\\] 搜索请求失败: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"plugin/cyg/cyg.go","lineNumber":115,"sourceCode":"\n// SearchWithResult 执行搜索并返回包含IsFinal标记的结果（推荐方法）\nfunc (p *CygPlugin) 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 *CygPlugin) searchImpl(client *http.Client, keyword string, ext map[string]interface{}) ([]model.SearchResult, error) {\n\t// 解析扩展参数\n\topts := p.parseExtOptions(ext)\n\n\t// 1. 构建搜索URL\n\tsearchURL := fmt.Sprintf(cygBaseURL+\"/wp-json/wp/v2/posts?per_page=%d&orderby=%s&order=%s&page=%d&search=%s\",\n\t\topts.PerPage, opts.OrderBy, opts.Order, opts.Page, url.QueryEscape(keyword))\n\n\t// 2. 发送搜索请求\n\tposts, err := p.fetchSearchResults(client, searchURL)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"[%s] 搜索请求失败: %w\", p.Name(), err)\n\t}\n\n\tif len(posts) == 0 {\n\t\treturn []model.SearchResult{}, nil\n\t}\n\n\t// 3. 并发获取每个帖子的下载链接\n\tresults := p.fetchDownloadLinksAsync(client, posts, keyword)\n\n\t// 4. 关键词过滤\n\tfilteredResults := plugin.FilterResultsByKeyword(results, keyword)\n\n\treturn filteredResults, nil\n}\n\n// fetchSearchResults 获取搜索结果列表\nfunc (p *CygPlugin) fetchSearchResults(client *http.Client, searchURL string) ([]CygPost, error) {\n\t// 创建带超时的上下文","sourceCodeStart":97,"sourceCodeEnd":133,"githubUrl":"https://github.com/fish2018/pansou/blob/beaa56133755a548ebc51b090b3816e2ae044aa6/plugin/cyg/cyg.go#L97-L133","documentation":"searchImpl in the cyg plugin wraps any failure from fetchSearchResults with this error, prefixed with the plugin name. It is a generic wrapper: the root cause is in the wrapped error (request creation, HTTP failure, bad status, read or JSON errors). The WordPress REST search query itself could not be completed.","triggerScenarios":"Any call path through SearchWithResult → searchImpl where fetchSearchResults returns an error: invalid search URL construction, network failure, non-200 status, body read failure, or JSON decode failure of the /wp-json/wp/v2/posts response.","commonSituations":"Upstream WordPress site is down or moved; keyword contains characters that break the URL; network/firewall blocks the request; the site no longer exposes the REST API.","solutions":["Unwrap the error (%w) to find the root cause; each underlying error has its own fix.","Test the constructed search URL directly in a browser/curl to confirm the REST endpoint responds.","Verify network connectivity and DNS for cygBaseURL from the host running the code.","Confirm the upstream still supports /wp-json/wp/v2/posts with the given per_page/orderby/order/page parameters."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"results, err := plugin.SearchWithResult(ctx, opts)\nif err != nil {\n    var wrapped interface{ Unwrap() error }\n    log.Printf(\"cyg search failed: %v (cause: %v)\", err, errors.Unwrap(err))\n    // decide retry vs fallback based on the unwrapped cause\n}","preventionTips":["Always inspect the wrapped cause with errors.Unwrap — this error is only a prefix","Verify the upstream REST endpoint is reachable from your deployment environment","Validate keyword/page inputs before calling search"],"tags":["http","wrapper-error","wordpress","go"],"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"}