{"record":{"id":"9843fdd22adb4bae","repo":"chenhg5/cc-connect","slug":"wecom-upload-image-failed-d-s","errorCode":null,"errorMessage":"wecom: upload image failed: %d %s","messagePattern":"wecom: upload image failed: (.+?) (.+?)","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"platform/wecom/wecom.go","lineNumber":582,"sourceCode":"\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\n}\n\nvar _ core.ImageSender = (*Platform)(nil)\n\nfunc (p *Platform) sendMarkdown(accessToken, toUser, content string) error {\n\tpayload := map[string]any{\n\t\t\"touser\":   toUser,\n\t\t\"msgtype\":  \"markdown\",\n\t\t\"agentid\":  p.agentID,\n\t\t\"markdown\": map[string]string{\"content\": content},\n\t}\n\n\tbody, _ := json.Marshal(payload)","sourceCodeStart":564,"sourceCodeEnd":600,"githubUrl":"https://github.com/chenhg5/cc-connect/blob/4000b2338aa6e850c99df54f8b0ed6ed7460b401/platform/wecom/wecom.go#L564-L600","documentation":"WeCom API rejection of the media upload: the response decoded as JSON but errcode was non-zero. Frequent causes: 40014/42001 expired access_token attached to the upload URL, 44001 media size exceeded, 45009 rate limiting, or invalid multipart content.","triggerScenarios":"Thrown at platform/wecom/wecom.go:582 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["On token errors, refresh the access_token and re-upload","On size errors (44001/41059), compress or downscale the image before upload","On 45009, back off and retry later","Log errcode/errmsg (already included) and map to user guidance"],"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"}