chenhg5/cc-connect · error

download: %w

Error message

download: %w

What it means

Transport-level failure of GET /cgi-bin/media/get: the HTTP request to download a media file by media_id did not complete (connection error, reset, DNS or TLS failure, timeout). Note the body is read even on non-200 statuses; this wrap only covers the request/transport error itself.

Source

Thrown at platform/wecom/wecom.go:890

	}
	if len(data) >= 4 && string(data[:4]) == "%PDF" {
		return "application/pdf"
	}
	return ""
}

func (p *Platform) downloadMedia(mediaID string) ([]byte, error) {
	accessToken, err := p.getAccessToken()
	if err != nil {
		return nil, fmt.Errorf("get token: %w", err)
	}
	u := p.wecomAPIURL("/cgi-bin/media/get", url.Values{
		"access_token": []string{accessToken},
		"media_id":     []string{mediaID},
	})
	resp, err := p.apiClient.Get(u)
	if err != nil {
		return nil, fmt.Errorf("download: %w", err)
	}
	defer resp.Body.Close()
	return io.ReadAll(resp.Body)
}

View on GitHub (pinned to 4000b2338a)

Solutions

  1. Retry the download with backoff — transient faults dominate
  2. Check outbound connectivity to qyapi.weixin.qq.com
  3. Verify the access_token/media_id are valid; expired tokens can yield unusable responses downstream
  4. Consider a size limit when reading the body to avoid unbounded memory use
Defensive patterns

Strategy: retry

When it happens

Trigger: Thrown at platform/wecom/wecom.go:890 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/729e7ac88e5d2cdc. Report an issue: GitHub.