{"record":{"id":"7966fc0083d3d788","repo":"sipeed/picoclaw","slug":"download-media-returned-http-d","errorCode":null,"errorMessage":"download media returned HTTP %d","messagePattern":"download media returned HTTP (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/channels/wecom/media.go","lineNumber":294,"sourceCode":"\tctx context.Context,\n\tscope, msgID, resourceURL, aesKey, fallbackExt string,\n) (string, error) {\n\tstore := c.GetMediaStore()\n\tif store == nil {\n\t\treturn \"\", fmt.Errorf(\"no media store available\")\n\t}\n\n\treq, err := http.NewRequestWithContext(ctx, http.MethodGet, resourceURL, nil)\n\tif err != nil {\n\t\treturn \"\", fmt.Errorf(\"create request: %w\", err)\n\t}\n\tresp, err := c.mediaClient.Do(req)\n\tif err != nil {\n\t\treturn \"\", fmt.Errorf(\"download media: %w\", err)\n\t}\n\tdefer resp.Body.Close()\n\tif resp.StatusCode != http.StatusOK {\n\t\treturn \"\", fmt.Errorf(\"download media returned HTTP %d\", resp.StatusCode)\n\t}\n\n\tdata, err := io.ReadAll(io.LimitReader(resp.Body, wecomOutboundMediaMaxBytes+1))\n\tif err != nil {\n\t\treturn \"\", fmt.Errorf(\"read media: %w\", err)\n\t}\n\tif len(data) > wecomOutboundMediaMaxBytes {\n\t\treturn \"\", fmt.Errorf(\"media too large\")\n\t}\n\n\tif aesKey != \"\" {\n\t\tkey, keyErr := decodeMediaAESKey(aesKey)\n\t\tif keyErr != nil {\n\t\t\treturn \"\", keyErr\n\t\t}\n\t\tdata, err = decryptAESCBC(key, data)\n\t\tif err != nil {\n\t\t\treturn \"\", fmt.Errorf(\"decrypt media: %w\", err)","sourceCodeStart":276,"sourceCodeEnd":312,"githubUrl":"https://github.com/sipeed/picoclaw/blob/49183d7e8daed0dba89ddbb6fcb60089401d9680/pkg/channels/wecom/media.go#L276-L312","documentation":"Returned by storeRemoteMedia when the media download request completed but the WeCom server answered with a non-200 status (the %d shows the code). Common causes: expired media URL (WeCom media links are short-lived), auth failure (400/401), or server errors (5xx).","triggerScenarios":"Thrown at pkg/channels/wecom/media.go:294 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["For 400/401: the media link or access token expired — re-fetch the media URL with a fresh access token before downloading","For 5xx/429: retry after backoff, WeCom endpoints are rate limited","Download media promptly after receiving the message instead of much later, since links expire"],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"49183d7e8daed0dba89ddbb6fcb60089401d9680","analyzedAt":"2026-08-15T21:55:41.315Z","contentChangedAt":"2026-08-15T21:55:41.315Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}