{"record":{"id":"22b771f81be73038","repo":"chenhg5/cc-connect","slug":"http-d-22b771","errorCode":null,"errorMessage":"HTTP %d","messagePattern":"HTTP %d","errorType":"http","errorClass":null,"httpStatus":null,"severity":"error","filePath":"platform/qq/qq.go","lineNumber":715,"sourceCode":"\t\tend := strings.Index(s[idx:], \"]\")\n\t\tif end < 0 {\n\t\t\tbreak\n\t\t}\n\t\ts = s[idx+end+1:]\n\t}\n\treturn result.String()\n}\n\nfunc downloadLargeFile(url string) ([]byte, string, error) {\n\tclient := &http.Client{Timeout: 120 * time.Second}\n\tresp, err := client.Get(url)\n\tif err != nil {\n\t\treturn nil, \"\", err\n\t}\n\tdefer resp.Body.Close()\n\n\tif resp.StatusCode != http.StatusOK {\n\t\treturn nil, \"\", fmt.Errorf(\"HTTP %d\", resp.StatusCode)\n\t}\n\n\tdata, err := io.ReadAll(resp.Body)\n\tif err != nil {\n\t\treturn nil, \"\", err\n\t}\n\n\tmime := resp.Header.Get(\"Content-Type\")\n\tif mime == \"\" {\n\t\tmime = http.DetectContentType(data)\n\t}\n\treturn data, mime, nil\n}\n\nfunc downloadFile(url string) ([]byte, string, error) {\n\tclient := &http.Client{Timeout: 30 * time.Second}\n\tresp, err := client.Get(url)\n\tif err != nil {","sourceCodeStart":697,"sourceCodeEnd":733,"githubUrl":"https://github.com/chenhg5/cc-connect/blob/4000b2338aa6e850c99df54f8b0ed6ed7460b401/platform/qq/qq.go#L697-L733","documentation":"downloadLargeFile in the QQ platform adapter performs an HTTP GET of a file (e.g. an image attachment) and only accepts status 200 OK. Any other status (404, 403, 5xx, redirects to error pages) aborts the download with this bare \"HTTP %d\" error carrying just the numeric status code, and the message parse that needed the file fails.","triggerScenarios":"Called from parseMessage when the platform needs to download an attachment whose URL returns a non-200 response: expired/signed media URLs, deleted media, auth failures on the CDN, or the QQ media server returning 5xx.","commonSituations":"QQ CDN links expire quickly; a message with an old attachment URL 403s. Media deleted before download. Transient 502/503 from Tencent servers. Network proxies that inject 4xx/5xx responses.","solutions":["Check the numeric status in the error message: 4xx means the URL/auth is bad (re-fetch the message to get a fresh media URL), 5xx means retry later.","Re-download promptly after receiving the message; QQ attachment URLs are short-lived.","Retry with backoff on 5xx statuses; treat 401/403/404 as non-retryable.","If it persists, verify outbound network/proxy access to the QQ media host from the machine running cc-connect."],"exampleFix":"// before\nif resp.StatusCode != http.StatusOK {\n\treturn nil, \"\", fmt.Errorf(\"HTTP %d\", resp.StatusCode)\n}\n// after\nif resp.StatusCode != http.StatusOK {\n\treturn nil, \"\", fmt.Errorf(\"qq: download media: unexpected status %d for %s\", resp.StatusCode, resp.Request.URL)\n}","handlingStrategy":"retry","validationCode":"if resp.StatusCode != http.StatusOK {\n\t// inspect resp.StatusCode before consuming the body\n\tif resp.StatusCode >= 500 { /* retry with backoff */ } else { /* URL expired/invalid: refresh media URL */ }\n}","typeGuard":null,"tryCatchPattern":"data, url, err := downloadFile(ctx, mediaURL)\nif err != nil {\n\tif strings.Contains(err.Error(), \"HTTP 5\") {\n\t\t// transient: retry with backoff\n\t} else {\n\t\t// 4xx: log and skip attachment, keep processing the message\n\t}\n}","preventionTips":["Download attachments immediately after message receipt — QQ media URLs expire quickly.","Classify status codes: retry 5xx, refresh credentials/URL for 401/403, give up on 404.","Monitor for repeated failures from the same media host (proxy/firewall issue)."],"tags":["network","http","qq"],"backgroundTag":"http-error-response","analyzedSha":"4000b2338aa6e850c99df54f8b0ed6ed7460b401","analyzedAt":"2026-09-06T11:45:09.575Z","contentChangedAt":"2026-09-06T11:45:09.575Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}