chenhg5/cc-connect · error
wecom: upload image: %w
Error message
wecom: upload image: %w
What it means
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.
Source
Thrown at platform/wecom/wecom.go:569
part, err := writer.CreateFormFile("media", name)
if err != nil {
return "", fmt.Errorf("wecom: create form file: %w", err)
}
if _, err := part.Write(img.Data); err != nil {
return "", fmt.Errorf("wecom: write image data: %w", err)
}
if err := writer.Close(); err != nil {
return "", fmt.Errorf("wecom: close multipart writer: %w", err)
}
apiURL := p.wecomAPIURL("/cgi-bin/media/upload", url.Values{
"access_token": []string{accessToken},
"type": []string{"image"},
})
resp, err := p.apiClient.Post(apiURL, writer.FormDataContentType(), body)
if err != nil {
return "", fmt.Errorf("wecom: upload image: %w", err)
}
defer resp.Body.Close()
var result struct {
ErrCode int `json:"errcode"`
ErrMsg string `json:"errmsg"`
MediaID string `json:"media_id"`
}
if err := json.NewDecoder(resp.Body).Decode(&result); err != nil {
return "", fmt.Errorf("wecom: decode upload response: %w", err)
}
if result.ErrCode != 0 {
return "", fmt.Errorf("wecom: upload image failed: %d %s", result.ErrCode, result.ErrMsg)
}
if result.MediaID == "" {
return "", fmt.Errorf("wecom: upload image: empty media_id")
}
return result.MediaID, nilView on GitHub (pinned to 4000b2338a)
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
Defensive patterns
Strategy: retry
When it happens
Trigger: Thrown at platform/wecom/wecom.go:569 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of chenhg5/cc-connect@4000b2338a (2026-09-06).
Data as JSON: /api/errors/b67e22828da39706.
Report an issue: GitHub.