sipeed/picoclaw · error

download media

Error message

download media: %w

What it means

Returned by storeRemoteMedia when the mediaClient HTTP round trip for the WeCom media download fails at the transport level — connection refused, timeout, DNS failure. The %w wraps the http.Client error; the response body was never received.

Solutions

  1. Check network egress to the WeCom media host (qyapi.weixin.qq.com or regional endpoint)
  2. Retry the download — transient connectivity failures are common
  3. Inspect the wrapped error for timeout vs DNS vs TLS to narrow the cause
  4. Confirm proxy settings if the environment requires one for outbound traffic
Defensive patterns

Strategy: retry

When it happens

Trigger: Thrown at pkg/channels/wecom/media.go:290 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of sipeed/picoclaw@49183d7e8d (2026-08-15). Data as JSON: /api/errors/e46183f6fa651cbd. Report an issue: GitHub.

Appendix: source

Thrown at pkg/channels/wecom/media.go:290

	return filename, contentType
}

func (c *WeComChannel) storeRemoteMedia(
	ctx context.Context,
	scope, msgID, resourceURL, aesKey, fallbackExt string,
) (string, error) {
	store := c.GetMediaStore()
	if store == nil {
		return "", fmt.Errorf("no media store available")
	}

	req, err := http.NewRequestWithContext(ctx, http.MethodGet, resourceURL, nil)
	if err != nil {
		return "", fmt.Errorf("create request: %w", err)
	}
	resp, err := c.mediaClient.Do(req)
	if err != nil {
		return "", fmt.Errorf("download media: %w", err)
	}
	defer resp.Body.Close()
	if resp.StatusCode != http.StatusOK {
		return "", fmt.Errorf("download media returned HTTP %d", resp.StatusCode)
	}

	data, err := io.ReadAll(io.LimitReader(resp.Body, wecomOutboundMediaMaxBytes+1))
	if err != nil {
		return "", fmt.Errorf("read media: %w", err)
	}
	if len(data) > wecomOutboundMediaMaxBytes {
		return "", fmt.Errorf("media too large")
	}

	if aesKey != "" {
		key, keyErr := decodeMediaAESKey(aesKey)
		if keyErr != nil {
			return "", keyErr

View on GitHub (pinned to 49183d7e8d)