chenhg5/cc-connect · error
tuitui: %s response exceeds %d bytes
Error message
tuitui: %s response exceeds %d bytes
What it means
postJSON caps API responses at maxJSONResponseBytes by reading LimitReader(size+1). If more bytes than the cap arrive, the response is treated as malformed/untrusted and rejected instead of being parsed. This protects memory from runaway responses.
Source
Thrown at platform/tuitui/tuitui.go:726
q.Set("appid", p.appID)
q.Set("secret", p.appSecret)
u.RawQuery = q.Encode()
req, err := http.NewRequestWithContext(ctx, http.MethodPost, u.String(), bytes.NewReader(data))
if err != nil {
return err
}
req.Header.Set("Content-Type", "application/json")
resp, err := p.client.Do(req)
if err != nil {
return errorsRedacted(err, p.appSecret)
}
defer func() { _ = resp.Body.Close() }()
body, err := io.ReadAll(io.LimitReader(resp.Body, maxJSONResponseBytes+1))
if err != nil {
return err
}
if len(body) > maxJSONResponseBytes {
return fmt.Errorf("tuitui: %s response exceeds %d bytes", apiPath, maxJSONResponseBytes)
}
if resp.StatusCode < 200 || resp.StatusCode >= 300 {
return fmt.Errorf("HTTP %d: %s", resp.StatusCode, body)
}
var apiResp struct {
ErrCode int `json:"errcode"`
ErrMsg string `json:"errmsg"`
}
if out != nil {
if err := json.Unmarshal(body, out); err != nil {
return fmt.Errorf("tuitui: decode %s response: %w (body_len=%d)", apiPath, err, len(body))
}
return nil
}
if len(bytes.TrimSpace(body)) == 0 {
return nil
}
if err := json.Unmarshal(body, &apiResp); err != nil {View on GitHub (pinned to 4000b2338a)
Solutions
- Reduce the requested page size/limit in the history fetch request so the response fits the cap.
- Raise maxJSONResponseBytes if legitimately large responses are expected in your deployment.
- Inspect what endpoint returns the oversized body (the %s in the message) and paginate instead of one large call.
- Check for a proxy/gateway returning unexpected huge bodies and fix the network path.
Example fix
// before resp := p.fetchChannelHistory(ctx, rctx, limit: 500) // > maxJSONResponseBytes // after resp := p.fetchChannelHistory(ctx, rctx, limit: 50) // paginate in a loop
Defensive patterns
Strategy: fallback
Try / catch
if err := p.postJSON(ctx, path, req, &out); err != nil {
if isOversizeErr(err) {
return p.paginatedFetch(ctx, rctx) // smaller pages
}
return err
} Prevention
- Request small page sizes for history endpoints
- Keep maxJSONResponseBytes large enough for expected payloads
- Monitor for proxies injecting large non-JSON bodies
When it happens
Trigger: Any postJSON caller (history fetch, getChannelInfo, reactToMessage, sendPayload) receiving a Tuitui API response body larger than maxJSONResponseBytes.
Common situations: Fetching channel/direct history for chats with huge accumulated messages; a misbehaving proxy returning huge HTML error pages; API version change inflating response payloads.
Understand the failure class
Background: payload too large / request exceeds maximum size: why libraries cap bytes and how to fix oversize payloads — this error's family across 50 libraries.
Related errors
- errcode=%d errmsg=%s
- HTTP %d: %s
- tuitui: decode %s response: %w (body_len=%d)
- missing --chat
- missing --q
AI-assisted analysis of chenhg5/cc-connect@4000b2338a (2026-09-06).
Data as JSON: /api/errors/63e07922caf4689f.
Report an issue: GitHub.