{"record":{"id":"057a569a668f7475","repo":"chenhg5/cc-connect","slug":"wecom-send-image-failed-d-s","errorCode":null,"errorMessage":"wecom: send image failed: %d %s","messagePattern":"wecom: send image failed: (.+?) (.+?)","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"platform/wecom/wecom.go","lineNumber":537,"sourceCode":"\tapiURL := p.wecomAPIURL(\"/cgi-bin/message/send\", url.Values{\n\t\t\"access_token\": []string{accessToken},\n\t})\n\n\tresp, err := p.apiClient.Post(apiURL, \"application/json\", strings.NewReader(string(body)))\n\tif err != nil {\n\t\treturn fmt.Errorf(\"wecom: send 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}\n\tif err := json.NewDecoder(resp.Body).Decode(&result); err != nil {\n\t\treturn fmt.Errorf(\"wecom: decode send image response: %w\", err)\n\t}\n\tif result.ErrCode != 0 {\n\t\treturn fmt.Errorf(\"wecom: send image failed: %d %s\", result.ErrCode, result.ErrMsg)\n\t}\n\treturn nil\n}\n\n// uploadImageMedia uploads an image to WeChat Work media API and returns the media_id.\nfunc (p *Platform) uploadImageMedia(accessToken string, img core.ImageAttachment) (string, error) {\n\tname := img.FileName\n\tif name == \"\" {\n\t\tname = \"image.png\"\n\t}\n\n\tbody := &bytes.Buffer{}\n\twriter := multipart.NewWriter(body)\n\n\tpart, err := writer.CreateFormFile(\"media\", name)\n\tif err != nil {\n\t\treturn \"\", fmt.Errorf(\"wecom: create form file: %w\", err)\n\t}","sourceCodeStart":519,"sourceCodeEnd":555,"githubUrl":"https://github.com/chenhg5/cc-connect/blob/4000b2338aa6e850c99df54f8b0ed6ed7460b401/platform/wecom/wecom.go#L519-L555","documentation":"WeCom API application-level rejection of the image message send: the response parsed as JSON but errcode was non-zero, with errmsg describing why. Common codes: 40014/42001 invalid or expired access_token, 45009 rate limit exceeded, 81013 invalid touser, or invalid media_id from a failed upload.","triggerScenarios":"Thrown at platform/wecom/wecom.go:537 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["For 40014/42001, force a token refresh (clear tokenCache) and resend once","For 45009, back off and respect the rate limit before retrying","For invalid media_id, re-upload the image via uploadImageMedia and retry the send","Map frequent errcodes to user-visible i18n messages instead of leaking raw codes"],"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"}