{"record":{"id":"791b2a7770164e52","repo":"fish2018/pansou","slug":"w-791b2a","errorCode":null,"errorMessage":"下载链接请求失败: %w","messagePattern":"下载链接请求失败: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"plugin/cyg/cyg.go","lineNumber":240,"sourceCode":"\tdownloadURL := fmt.Sprintf(cygBaseURL+\"/wp-json/acg-studio/v1/download?id=%d\", postID)\n\n\t// 创建带超时的上下文\n\tctx, cancel := context.WithTimeout(context.Background(), 30*time.Second)\n\tdefer cancel()\n\n\t// 创建请求对象\n\treq, err := http.NewRequestWithContext(ctx, \"GET\", downloadURL, nil)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"创建下载链接请求失败: %w\", err)\n\t}\n\n\t// 设置请求头\n\tp.setRequestHeaders(req)\n\n\t// 发送请求\n\tresp, err := p.doRequestWithRetry(req, client)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"下载链接请求失败: %w\", err)\n\t}\n\tdefer resp.Body.Close()\n\n\t// 检查状态码\n\tif resp.StatusCode != 200 {\n\t\treturn nil, fmt.Errorf(\"下载链接请求状态码: %d\", resp.StatusCode)\n\t}\n\n\t// 解析响应\n\tbody, err := io.ReadAll(resp.Body)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"读取下载链接响应失败: %w\", err)\n\t}\n\n\tvar downloadData []CygDownload\n\tif err := json.Unmarshal(body, &downloadData); err != nil {\n\t\treturn nil, fmt.Errorf(\"下载链接JSON解析失败: %w\", err)\n\t}","sourceCodeStart":222,"sourceCodeEnd":258,"githubUrl":"https://github.com/fish2018/pansou/blob/beaa56133755a548ebc51b090b3816e2ae044aa6/plugin/cyg/cyg.go#L222-L258","documentation":"getDownloadLinks in the cyg plugin wraps any transport-level failure of the HTTP request used to fetch download links with the prefix \"下载链接请求失败\". It means p.doRequestWithRetry exhausted its attempts (network error, DNS failure, timeout) or returned a non-nil error. The original cause is preserved via %w so errors.Is/As on the wrapped error works.","triggerScenarios":"Calling the plugin's download-link lookup when the GET to the cyg API fails at the transport layer in doRequestWithRetry: network unreachable, TLS error, request context timeout, or all retry attempts exhausted with a non-HTTP error.","commonSituations":"Offline or flaky network, the site blocking the client (TLS reset / anti-bot), DNS resolution failure, or a too-short HTTP client timeout while fetching download links.","solutions":["Inspect the wrapped cause (errors.Unwrap / %v of the returned error) to see whether it is a timeout, DNS, or TLS failure.","Verify network connectivity and that https://www.cygtu.com (or the configured host) is reachable, e.g. with curl.","Increase the HTTP client timeout or retry count used by doRequestWithRetry.","Check whether the target site now requires headers/cookies the plugin does not send (site layout/anti-bot change) and update setRequestHeaders."],"exampleFix":"// before\nlinks, err := p.getDownloadLinks(id)\nif err != nil {\n    return err // opaque Chinese-wrapped error\n}\n// after\nlinks, err := p.getDownloadLinks(id)\nif err != nil {\n    var ne net.Error\n    if errors.As(err, &ne) && ne.Timeout() {\n        return fmt.Errorf(\"download links timed out, increase client timeout: %w\", err)\n    }\n    return err\n}","handlingStrategy":"try-catch","validationCode":"url, _ := url.Parse(baseURL)\nif url == nil || url.Host == \"\" {\n    return fmt.Errorf(\"unreachable base url\")\n}","typeGuard":null,"tryCatchPattern":"links, err := p.getDownloadLinks(id)\nif err != nil {\n    var ne net.Error\n    if errors.As(err, &ne) && ne.Timeout() {\n        // retry with longer timeout\n    }\n    return nil, fmt.Errorf(\"download links unavailable: %w\", err)\n}","preventionTips":["Set a generous HTTP client timeout before calling search/download APIs.","Unwrap and classify the error (timeout vs DNS vs TLS) before deciding to retry.","Monitor the target site's availability; the plugin cannot help if the host is blocked."],"tags":["network","http","go","retry"],"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"}