{"record":{"id":"c5231cb0faaac848","repo":"fish2018/pansou","slug":"cookie-jar-w","errorCode":null,"errorMessage":"创建cookie jar失败: %w","messagePattern":"创建cookie jar失败: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"plugin/qupanshe/qupanshe.go","lineNumber":123,"sourceCode":"\tif DebugLog {\n\t\tfmt.Printf(\"[qupanshe] 获取搜索结果成功: 结果数=%d\\n\", len(results))\n\t}\n\n\t// Step 4: 关键词过滤\n\tfilteredResults := plugin.FilterResultsByKeyword(results, keyword)\n\tif DebugLog {\n\t\tfmt.Printf(\"[qupanshe] 关键词过滤后: 过滤前=%d, 过滤后=%d\\n\", len(results), len(filteredResults))\n\t}\n\n\treturn filteredResults, nil\n}\n\n// createSessionClient 创建带有Cookie管理的HTTP客户端\nfunc (p *QupanshePlugin) createSessionClient(baseClient *http.Client) (*http.Client, error) {\n\t// 创建Cookie Jar来管理cookies\n\tjar, err := cookiejar.New(nil)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"创建cookie jar失败: %w\", err)\n\t}\n\n\t// 创建新的客户端，复制基础客户端的配置但添加Cookie管理\n\tsessionClient := &http.Client{\n\t\tTimeout:   baseClient.Timeout,\n\t\tTransport: baseClient.Transport,\n\t\tJar:       jar, // ⭐ 关键：添加Cookie管理\n\t}\n\n\tif DebugLog {\n\t\tfmt.Printf(\"[qupanshe] 创建带Cookie管理的session客户端，超时时间: %v\\n\", sessionClient.Timeout)\n\t}\n\n\treturn sessionClient, nil\n}\n\n// getFormhash 从首页获取真实的formhash值\nfunc (p *QupanshePlugin) getFormhash(client *http.Client) (string, error) {","sourceCodeStart":105,"sourceCodeEnd":141,"githubUrl":"https://github.com/fish2018/pansou/blob/beaa56133755a548ebc51b090b3816e2ae044aa6/plugin/qupanshe/qupanshe.go#L105-L141","documentation":"createSessionClient wraps a failure from cookiejar.New, which initializes the cookie jar used to keep the same session across all search steps. The library returns this when a cookie jar cannot be constructed for the session client.","triggerScenarios":"cookiejar.New(nil) returns a non-nil error inside createSessionClient, invoked by searchImpl before any HTTP traffic. With nil Options this effectively never fails on mainstream platforms.","commonSituations":"Practically only seen on unusual runtimes (restricted sandboxes, exotic OS/arch builds) or if code was modified to pass invalid jar Options (e.g., invalid PublicSuffixList).","solutions":["Retry the operation — the condition is transient/environmental if seen at all","Inspect the wrapped cause from %w","If custom Options were added to cookiejar.New, verify they are valid (especially PublicSuffixList)","Report a bug with environment details if reproducible"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"results, err := plugin.Search(ctx, keyword)\nif err != nil && strings.Contains(err.Error(), \"创建cookie jar失败\") {\n    // environmental failure: log env details and retry once\n    return retryOnce(err)\n}","preventionTips":["Avoid custom cookiejar.New options unless validated","Test on target platforms before deployment","Treat occurrences as environment bugs, not user errors"],"tags":["go","cookie-jar","http-client"],"backgroundTag":"module-init-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"}