chenhg5/cc-connect · error
empty url
Error message
empty url
What it means
downloadAttachment refuses to issue an HTTP GET when the supplied URL is the empty string. The URL is normally a pre-signed CDN link taken from a MAX message payload; an empty value means the payload never contained one.
Source
Thrown at platform/max/max.go:1184
return sub
}
}
}
if filename != "" {
if i := strings.LastIndex(filename, "."); i >= 0 && i < len(filename)-1 {
return strings.ToLower(filename[i+1:])
}
}
return "ogg"
}
// downloadAttachment GETs an arbitrary URL (typically a pre-signed CDN link
// from MAX), capping the response at maxAttachmentBytes. The URLs MAX serves
// for image/file payloads are already authenticated, so no bot token is
// attached to the request.
func (p *Platform) downloadAttachment(ctx context.Context, url string) ([]byte, string, error) {
if url == "" {
return nil, "", fmt.Errorf("empty url")
}
dlCtx, cancel := context.WithTimeout(ctx, attachmentDownloadTO)
defer cancel()
req, err := http.NewRequestWithContext(dlCtx, http.MethodGet, url, nil)
if err != nil {
return nil, "", err
}
resp, err := p.client.Do(req)
if err != nil {
return nil, "", err
}
defer resp.Body.Close()
if resp.StatusCode != http.StatusOK {
return nil, "", fmt.Errorf("HTTP %d", resp.StatusCode)
}
data, err := io.ReadAll(io.LimitReader(resp.Body, maxAttachmentBytes+1))
if err != nil {
return nil, "", errView on GitHub (pinned to 4000b2338a)
Solutions
- Check url != "" (or validate the attachment object) before calling downloadAttachment
- Use resolveMediaURL for video/audio attachments that only provide a token
- Log the raw attachment JSON when the URL is missing to identify the message type
- Skip or placeholder the attachment in the outgoing message instead of failing
Example fix
// before
data, ct, err := p.downloadAttachment(ctx, att.URL)
// after
if att.URL == "" {
return skipAttachment(att)
}
data, ct, err := p.downloadAttachment(ctx, att.URL) Defensive patterns
Strategy: validation
Validate before calling
if url == "" { return skipOrPlaceholder(attachment) } Prevention
- Validate attachment URL/token presence when parsing incoming MAX messages
- Log raw attachment JSON for payloads lacking URLs
- Route video/audio through resolveMediaURL instead of downloadAttachment
When it happens
Trigger: A MAX image/file message arrives whose attachment object has an empty url field and the platform calls downloadAttachment with that value directly.
Common situations: Processing message types that carry attachments without download URLs (e.g. stickers, voice handled via tokens instead of URLs); MAX API change removing the url field; upstream sender sending malformed attachments.
Understand the failure class
Background: "must not be empty", "cannot be empty" — required-field validation errors across open-source libraries — this error's family across 41 libraries.
Related errors
- %s is not an image (detected mime: %s)
- %s is not %s media (detected mime: %s)
- attachment %s exceeds size limit (%d MB)
- empty token
- max: send message: attachment not ready after %d retries
AI-assisted analysis of chenhg5/cc-connect@4000b2338a (2026-09-06).
Data as JSON: /api/errors/53b3fe4fe5e1a221.
Report an issue: GitHub.