router-for-me/CLIProxyAPI · error
response exceeds maximum allowed size of %d bytes
Error message
response exceeds maximum allowed size of %d bytes
What it means
A download from the plugin store GitHub API returned a body larger than the caller's maxSize limit (enforced via io.LimitReader with maxSize+1). The client downloads release assets and API payloads through a bounded reader; when len(data) exceeds maxSize the fetch is rejected outright. This protects against unexpectedly huge responses such as a mis-published asset or a proxy/HTML error page masquerading as content.
Source
Thrown at internal/pluginstore/github.go:284
}
}()
if resp.StatusCode < http.StatusOK || resp.StatusCode >= http.StatusMultipleChoices {
if authenticated {
return nil, fmt.Errorf("unexpected status %d", resp.StatusCode)
}
body, _ := io.ReadAll(io.LimitReader(resp.Body, 4096))
return nil, fmt.Errorf("unexpected status %d: %s", resp.StatusCode, strings.TrimSpace(string(body)))
}
reader := io.Reader(resp.Body)
if maxSize > 0 {
reader = io.LimitReader(resp.Body, maxSize+1)
}
data, errRead := io.ReadAll(reader)
if errRead != nil {
return nil, fmt.Errorf("read response: %w", errRead)
}
if maxSize > 0 && int64(len(data)) > maxSize {
return nil, fmt.Errorf("response exceeds maximum allowed size of %d bytes", maxSize)
}
return data, nil
}
func pluginStoreRequestError(requestURL string, err error) error {
parsed, errParse := url.Parse(strings.TrimSpace(requestURL))
safeURL := "plugin store url"
if errParse == nil && parsed.Scheme != "" && parsed.Host != "" {
parsed.User = nil
parsed.RawQuery = ""
parsed.ForceQuery = false
parsed.Fragment = ""
safeURL = parsed.String()
}
var urlError *url.Error
if errors.As(err, &urlError) && urlError.Err != nil {
err = urlError.Err
}View on GitHub (pinned to 78f0c4079e)
Solutions
- If downloading a release archive, use the asset download path (DownloadAsset) rather than the metadata fetch that enforces the smaller cap
- Raise the maxSize argument passed to the fetch helper to exceed the real asset size (check the release's asset size field)
- Check the request URL — an HTML error page means auth/rate-limit trouble, not a size problem; fix the underlying HTTP status
- Verify the correct release tag/asset is being fetched (wrong asset name can hit an oversized page)
Example fix
// before data, err := client.fetch(ctx, metadataURL, 1<<20) // metadata cap used for archive // after asset, checksum, err := pluginstore.SelectReleaseAssets(release, id, version, runtime.GOOS, runtime.GOARCH) // ... archiveData, err := client.DownloadAsset(ctx, asset)
Defensive patterns
Strategy: validation
Validate before calling
// Before fetching, confirm expected size fits the cap you pass.
if expected > 0 && expected > maxSize {
return fmt.Errorf("asset %s is %d bytes, exceeds cap %d", name, expected, maxSize)
} Try / catch
if err != nil && strings.Contains(err.Error(), "response exceeds maximum allowed size") {
// re-fetch via the asset download path with an adequate/no cap, or reject the asset
} Prevention
- Use the metadata fetch path only for JSON and the asset path for binaries
- Pass a maxSize comfortably larger than the largest legitimate payload
- Treat oversized 'JSON' responses as a signal the URL is wrong (HTML error page)
When it happens
Trigger: Calling the GitHub helper's fetch path (used by FetchReleaseByTag / DownloadAsset) where the server returns more bytes than the configured maxSize > 0. Common with large plugin archives downloaded through the metadata-fetch code path instead of the asset-download path, or when a redirect/HTML page is returned.
Common situations: Downloading a plugin release archive whose size exceeds the metadata size cap; a CDN or captive portal returning an oversized HTML page; maxSize defaults tuned for JSON being used for binary artifacts.
Related errors
- download %s: %w
- download checksums.txt: %w
- download artifact: %w
- artifact exceeds declared size
- decode release: %w
AI-assisted analysis of router-for-me/CLIProxyAPI@78f0c4079e (2026-08-15).
Data as JSON: /api/errors/b1c0d75828d7155a.
Report an issue: GitHub.