chenhg5/cc-connect · error
empty token
Error message
empty token
What it means
resolveMediaURL was called with an empty attachment token. MAX delivers only an opaque token in message payloads for video/audio; an empty token means the payload had no resolvable media reference and the /videos/{token} or /audios/{token} call cannot be built.
Source
Thrown at platform/max/max.go:1215
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, "", err
}
if len(data) > maxAttachmentBytes {
return nil, "", fmt.Errorf("attachment exceeds %d bytes", maxAttachmentBytes)
}
return data, resp.Header.Get("Content-Type"), nil
}
// resolveMediaURL asks MAX for the playable/downloadable URL of a video or
// audio attachment. MAX delivers only an opaque token in the message payload
// and exposes /videos/{token} and /audios/{token} for resolution.
func (p *Platform) resolveMediaURL(ctx context.Context, kind, token string) (string, string, error) {
if token == "" {
return "", "", fmt.Errorf("empty token")
}
endpoint := "/videos/"
if kind == "audio" {
endpoint = "/audios/"
}
req, err := http.NewRequestWithContext(ctx, http.MethodGet, p.apiBase+endpoint+token, nil)
if err != nil {
return "", "", err
}
p.setAuth(req)
resp, err := p.client.Do(req)
if err != nil {
return "", "", err
}
defer resp.Body.Close()
if resp.StatusCode != http.StatusOK {
body, _ := io.ReadAll(io.LimitReader(resp.Body, 512))View on GitHub (pinned to 4000b2338a)
Solutions
- Validate token != "" before calling resolveMediaURL and skip the attachment if empty
- Log the raw message payload to confirm the token field name and presence
- Check the MAX API version for renamed token fields
- Fall back to showing a placeholder in the bridged message
Example fix
// before
u, ct, err := p.resolveMediaURL(ctx, "video", att.Token)
// after
if att.Token == "" {
return nil, "", fmt.Errorf("max: attachment %s has no media token", att.ID)
}
u, ct, err := p.resolveMediaURL(ctx, "video", att.Token) Defensive patterns
Strategy: validation
Validate before calling
if token == "" { return placeholderForMissingMedia(msg) } Prevention
- Validate token presence when decoding incoming media messages
- Keep field names aligned with the MAX payload schema
- Degrade to a placeholder rather than failing the whole message relay
When it happens
Trigger: A video or audio message arrives whose token field is empty/missing and the platform calls resolveMediaURL with that token.
Common situations: Media deleted upstream before the bot processed it; MAX schema change renaming the token field; non-media message misrouted into the media resolution path.
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 url
- weixin: %s: empty payload
AI-assisted analysis of chenhg5/cc-connect@4000b2338a (2026-09-06).
Data as JSON: /api/errors/efb4b5c561cf6ad2.
Report an issue: GitHub.