{"record":{"id":"b67e22828da39706","repo":"chenhg5/cc-connect","slug":"wecom-upload-image-w","errorCode":null,"errorMessage":"wecom: upload image: %w","messagePattern":"wecom: upload image: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"platform/wecom/wecom.go","lineNumber":569,"sourceCode":"\n\tpart, err := writer.CreateFormFile(\"media\", name)\n\tif err != nil {\n\t\treturn \"\", fmt.Errorf(\"wecom: create form file: %w\", err)\n\t}\n\tif _, err := part.Write(img.Data); err != nil {\n\t\treturn \"\", fmt.Errorf(\"wecom: write image data: %w\", err)\n\t}\n\tif err := writer.Close(); err != nil {\n\t\treturn \"\", fmt.Errorf(\"wecom: close multipart writer: %w\", err)\n\t}\n\n\tapiURL := p.wecomAPIURL(\"/cgi-bin/media/upload\", url.Values{\n\t\t\"access_token\": []string{accessToken},\n\t\t\"type\":         []string{\"image\"},\n\t})\n\tresp, err := p.apiClient.Post(apiURL, writer.FormDataContentType(), body)\n\tif err != nil {\n\t\treturn \"\", fmt.Errorf(\"wecom: upload image: %w\", err)\n\t}\n\tdefer resp.Body.Close()\n\n\tvar result struct {\n\t\tErrCode int    `json:\"errcode\"`\n\t\tErrMsg  string `json:\"errmsg\"`\n\t\tMediaID string `json:\"media_id\"`\n\t}\n\tif err := json.NewDecoder(resp.Body).Decode(&result); err != nil {\n\t\treturn \"\", fmt.Errorf(\"wecom: decode upload response: %w\", err)\n\t}\n\tif result.ErrCode != 0 {\n\t\treturn \"\", fmt.Errorf(\"wecom: upload image failed: %d %s\", result.ErrCode, result.ErrMsg)\n\t}\n\tif result.MediaID == \"\" {\n\t\treturn \"\", fmt.Errorf(\"wecom: upload image: empty media_id\")\n\t}\n\treturn result.MediaID, nil","sourceCodeStart":551,"sourceCodeEnd":587,"githubUrl":"https://github.com/chenhg5/cc-connect/blob/4000b2338aa6e850c99df54f8b0ed6ed7460b401/platform/wecom/wecom.go#L551-L587","documentation":"Transport-level failure of POST /cgi-bin/media/upload (the HTTP request to the WeCom server did not complete): connection refused/reset, DNS failure, TLS error, or timeout. This fires before any response status is examined and is distinct from the errcode-based upload failures.","triggerScenarios":"Thrown at platform/wecom/wecom.go:569 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Retry with backoff — transient network faults are the dominant cause","Check outbound connectivity/firewall rules to qyapi.weixin.qq.com","Verify corporate proxy settings if the host routes through one","If persistent, check the WeCom service status"],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"4000b2338aa6e850c99df54f8b0ed6ed7460b401","analyzedAt":"2026-09-06T11:45:09.575Z","contentChangedAt":"2026-09-06T11:45:09.575Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}