{"record":{"id":"97706631c00f0870","repo":"chenhg5/cc-connect","slug":"wecom-decode-send-image-response-w","errorCode":null,"errorMessage":"wecom: decode send image response: %w","messagePattern":"wecom: decode send image response: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"platform/wecom/wecom.go","lineNumber":534,"sourceCode":"\t}\n\n\tbody, _ := json.Marshal(payload)\n\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)","sourceCodeStart":516,"sourceCodeEnd":552,"githubUrl":"https://github.com/chenhg5/cc-connect/blob/4000b2338aa6e850c99df54f8b0ed6ed7460b401/platform/wecom/wecom.go#L516-L552","documentation":"JSON decode failure while reading the WeCom message/send API response body for an image send: the server returned a non-JSON body (gateway error page, empty body) so the errcode/errmsg envelope could not be parsed.","triggerScenarios":"Thrown at platform/wecom/wecom.go:534 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Log a snippet of the raw body to identify what the server actually returned","Retry once — transient gateway responses frequently decode fine on the next attempt","If a WAF/proxy sits in front of qyapi.weixin.qq.com, whitelist it for the API host","Verify the access_token was appended correctly; some auth failures return non-JSON bodies"],"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"}