{"record":{"id":"0c3f481cb4ceda2f","repo":"fish2018/pansou","slug":"quarkres-request-failed-w","errorCode":null,"errorMessage":"[quarkres] request failed: %w","messagePattern":"\\[quarkres\\] request failed: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"plugin/quarkres/quarkres.go","lineNumber":95,"sourceCode":"}\n\n// doSearch 实际的搜索实现\nfunc (p *QuarkResPlugin) doSearch(client *http.Client, keyword string, ext map[string]interface{}) ([]model.SearchResult, error) {\n\tsearchURL := apiBase + url.QueryEscape(keyword)\n\n\treq, err := http.NewRequest(\"GET\", searchURL, nil)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"[quarkres] create request failed: %w\", err)\n\t}\n\treq.Header.Set(\"User-Agent\", \"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/126.0.0.0 Safari/537.36\")\n\treq.Header.Set(\"Accept\", \"application/json, text/plain, */*\")\n\treq.Header.Set(\"Accept-Language\", \"zh-CN,zh;q=0.9\")\n\treq.Header.Set(\"Connection\", \"keep-alive\")\n\treq.Header.Set(\"Referer\", \"https://squark.cc.cd/\")\n\n\tresp, err := client.Do(req)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"[quarkres] request failed: %w\", err)\n\t}\n\tdefer resp.Body.Close()\n\n\tif resp.StatusCode != 200 {\n\t\treturn nil, fmt.Errorf(\"[quarkres] HTTP %d\", resp.StatusCode)\n\t}\n\n\tbodyBytes, err := io.ReadAll(resp.Body)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"[quarkres] read response failed: %w\", err)\n\t}\n\n\tvar ar apiResp\n\tif err := json.Unmarshal(bodyBytes, &ar); err != nil {\n\t\treturn nil, fmt.Errorf(\"[quarkres] decode response failed: %w\", err)\n\t}\n\n\tif ar.Code != 200 {","sourceCodeStart":77,"sourceCodeEnd":113,"githubUrl":"https://github.com/fish2018/pansou/blob/beaa56133755a548ebc51b090b3816e2ae044aa6/plugin/quarkres/quarkres.go#L77-L113","documentation":"doSearch executes the request via client.Do; a transport-level failure is wrapped as \"[quarkres] request failed\". Note there is no retry here (unlike quark4k), so a single transient network error aborts the search immediately.","triggerScenarios":"client.Do(req) returns an error — DNS failure, connection refused/reset, TLS handshake failure, or context timeout when contacting squark.cc.cd.","commonSituations":"The squark.cc.cd domain is down, expired, or blocked from the host's network; DNS misconfiguration; corporate proxy with TLS interception; no retry means a single blip kills the search.","solutions":["Inspect the wrapped %w error to distinguish DNS vs connection vs TLS causes.","Test reachability of squark.cc.cd manually (curl -v) from the same host.","Add a small retry loop with backoff around client.Do for transient failures.","Set an explicit client Timeout and route via a proxy if the domain is blocked on your network."],"exampleFix":"// before\nresp, err := client.Do(req)\nif err != nil {\n    return nil, fmt.Errorf(\"[quarkres] request failed: %w\", err)\n}\n// after\nvar resp *http.Response\nfor attempt := 0; attempt < 3; attempt++ {\n    resp, err = client.Do(req)\n    if err == nil {\n        break\n    }\n    time.Sleep(time.Duration(attempt+1) * 500 * time.Millisecond)\n}\nif err != nil {\n    return nil, fmt.Errorf(\"[quarkres] request failed: %w\", err)\n}","handlingStrategy":"retry","validationCode":"if err := net.DialTimeout(\"tcp\", \"squark.cc.cd:443\", 3*time.Second); err != nil {\n    return fmt.Errorf(\"quarkres endpoint unreachable: %w\", err)\n}","typeGuard":null,"tryCatchPattern":"results, err := p.doSearch(client, keyword, ext)\nif err != nil {\n    var netErr net.Error\n    if errors.As(err, &netErr) && netErr.Timeout() {\n        // retry with backoff or fail gracefully with empty results\n    }\n}","preventionTips":["Add a retry loop with backoff around client.Do (none exists today)","Set an explicit http.Client timeout instead of relying on defaults","Pre-flight the domain's reachability/DNS at plugin startup","Route through a proxy if the target domain is blocked on your network"],"tags":["network","http","timeout"],"backgroundTag":"http-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"}