{"record":{"id":"8b48b629f53024b5","repo":"fish2018/pansou","slug":"get-w","errorCode":null,"errorMessage":"创建GET请求失败: %w","messagePattern":"创建GET请求失败: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"plugin/qupanshe/qupanshe.go","lineNumber":147,"sourceCode":"\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) {\n\tctx, cancel := context.WithTimeout(context.Background(), 15*time.Second)\n\tdefer cancel()\n\n\treq, err := http.NewRequestWithContext(ctx, \"GET\", BaseURL, nil)\n\tif err != nil {\n\t\treturn \"\", fmt.Errorf(\"创建GET请求失败: %w\", err)\n\t}\n\n\tp.setRequestHeaders(req)\n\n\tif DebugLog {\n\t\tfmt.Printf(\"[qupanshe] 请求首页获取formhash: %s\\n\", BaseURL)\n\t}\n\n\tresp, err := client.Do(req)\n\tif err != nil {\n\t\treturn \"\", fmt.Errorf(\"GET请求失败: %w\", err)\n\t}\n\tdefer resp.Body.Close()\n\n\t// 调试：显示从首页获取的cookies\n\tif DebugLog && client.Jar != nil {\n\t\tif u, _ := url.Parse(BaseURL); u != nil {\n\t\t\tcookies := client.Jar.Cookies(u)","sourceCodeStart":129,"sourceCodeEnd":165,"githubUrl":"https://github.com/fish2018/pansou/blob/beaa56133755a548ebc51b090b3816e2ae044aa6/plugin/qupanshe/qupanshe.go#L129-L165","documentation":"getFormhash wraps a failure from http.NewRequestWithContext when building the GET request for the site homepage used to extract formhash. This means the request object could not be constructed before any network I/O.","triggerScenarios":"http.NewRequestWithContext(ctx, \"GET\", BaseURL, nil) errors, which happens only when the method or URL is invalid — e.g., BaseURL fails url.Parse (malformed URL, control characters).","commonSituations":"BaseURL constant corrupted by an edit or bad build-time substitution, or accidentally containing whitespace/newlines/invalid characters.","solutions":["Check the BaseURL constant is a valid absolute HTTP(S) URL","Print/log BaseURL to spot stray whitespace or invalid characters","Fix the URL value; this is a compile-time/config issue, not a runtime network issue"],"exampleFix":"// before\nconst BaseURL = \"http://example.com base\"\n// after\nconst BaseURL = \"http://example.com\"","handlingStrategy":"validation","validationCode":"u, err := url.Parse(BaseURL)\nif err != nil || u.Scheme == \"\" || u.Host == \"\" {\n    // BaseURL is malformed; fix configuration before calling Search\n}","typeGuard":"func isValidURL(s string) bool {\n    u, err := url.Parse(s)\n    return err == nil && (u.Scheme == \"http\" || u.Scheme == \"https\") && u.Host != \"\"\n}","tryCatchPattern":null,"preventionTips":["Keep BaseURL as a vetted constant; validate with url.Parse at init","Avoid string concatenation that can inject whitespace into URLs"],"tags":["go","http-request","invalid-url"],"backgroundTag":"invalid-url","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"}