{"record":{"id":"99d5ba79ee02bc73","repo":"fish2018/pansou","slug":"searchid-v","errorCode":null,"errorMessage":"获取searchid失败: %v","messagePattern":"获取searchid失败: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"plugin/clxiong/clxiong.go","lineNumber":71,"sourceCode":"\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn result.Results, nil\n}\n\n// SearchWithResult 搜索并返回详细结果\nfunc (p *ClxiongPlugin) SearchWithResult(keyword string, ext map[string]interface{}) (*model.PluginSearchResult, error) {\n\tif p.debugMode {\n\t\tlog.Printf(\"[CLXIONG] 开始搜索: %s\", keyword)\n\t}\n\n\t// 第一步：POST搜索获取searchid\n\tsearchID, err := p.getSearchID(keyword)\n\tif err != nil {\n\t\tif p.debugMode {\n\t\t\tlog.Printf(\"[CLXIONG] 获取searchid失败: %v\", err)\n\t\t}\n\t\treturn nil, fmt.Errorf(\"获取searchid失败: %v\", err)\n\t}\n\n\t// 第二步：GET搜索结果\n\tresults, err := p.getSearchResults(searchID, keyword)\n\tif err != nil {\n\t\tif p.debugMode {\n\t\t\tlog.Printf(\"[CLXIONG] 获取搜索结果失败: %v\", err)\n\t\t}\n\t\treturn nil, err\n\t}\n\n\t// 第三步：同步获取详情页磁力链接\n\tresults = p.fetchDetailLinksSync(results)\n\n\tif p.debugMode {\n\t\tlog.Printf(\"[CLXIONG] 搜索完成，获得 %d 个结果\", len(results))\n\t}\n","sourceCodeStart":53,"sourceCodeEnd":89,"githubUrl":"https://github.com/fish2018/pansou/blob/beaa56133755a548ebc51b090b3816e2ae044aa6/plugin/clxiong/clxiong.go#L53-L89","documentation":"ClxiongPlugin.SearchWithResult fails in its first phase: p.getSearchID(keyword) could not obtain the searchid token needed for the two-step search (POST to get a 302 redirect whose Location header carries the searchid, then GET results). The underlying cause is wrapped with %v (loses errors.Is/As chains) and, when debugMode is on, also logged. Without a searchid the second GET cannot proceed, so Search fails entirely.","triggerScenarios":"Search -> SearchWithResult -> getSearchID returns an error: the POST timed out, connection failed, retry budget exhausted, or the server responded with a status other than 301/302 (or an empty Location header). SearchWithResult then returns fmt.Errorf(\"获取searchid失败: %v\", err).","commonSituations":"The clxiong endpoint stopped issuing 302 redirects after a site update; anti-bot protection returns 200 with a challenge page instead of a redirect; rate limiting returns 429; the environment cannot reach the site (offline/CI).","solutions":["Enable debugMode or inspect the wrapped error to see the underlying cause (transport failure vs unexpected status).","If the inner error is \"期望302重定向\" with a 200 status, the site likely changed flow or is serving an anti-bot page — capture the response body and update getSearchID accordingly.","Check connectivity and rate limits; slow down request frequency if 429 appears.","Increase timeouts/retries in getSearchID if the POST intermittently times out.","Prefer %w over %v when wrapping so callers can use errors.Is on the root cause."],"exampleFix":"// before\nreturn nil, fmt.Errorf(\"获取searchid失败: %v\", err)\n// after\nreturn nil, fmt.Errorf(\"获取searchid失败: %w\", err) // enables errors.Is/As on the root cause","handlingStrategy":"try-catch","validationCode":"// ensure keyword is usable before the two-step flow\nif strings.TrimSpace(keyword) == \"\" { return nil, errors.New(\"keyword required\") }","typeGuard":null,"tryCatchPattern":"results, err := plugin.Search(ctx, keyword)\nif err != nil {\n    if strings.Contains(err.Error(), \"获取searchid失败\") {\n        // first phase failed: check wrapped cause; retry once after backoff\n        time.Sleep(2 * time.Second)\n        results, err = plugin.Search(ctx, keyword)\n    }\n    if err != nil { return nil, err }\n}","preventionTips":["Use %w instead of %v when wrapping so callers can inspect root causes.","Enable debugMode during integration to capture getSearchID internals.","Monitor for site flow changes — a 200 response where 302 was expected means the flow changed.","Throttle requests to avoid rate-limit-triggered failures in phase one."],"tags":["http","scraping","two-step-search","token"],"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"}