chenhg5/cc-connect · error
range status %d body=%q
Error message
range status %d body=%q
What it means
When a range request returns a non-206 status in the 5xx band, resourceRangeChunk records 'range status %d body=%q' as lastErr and retries; if retries are exhausted or the status is not retryable, this error is returned (wrapped by 'range chunk retries exhausted' when it was the retained lastErr). The body snippet (up to 4 KiB) is included for diagnostics.
Source
Thrown at platform/feishu/resource_download.go:364
if isTransientError(err) && attempt < maxTransientRetries {
lastErr = err
continue
}
return nil, fmt.Errorf("read range body: %w", err)
}
if int64(len(body)) != end-start+1 {
return nil, fmt.Errorf("range body length %d != requested %d", len(body), end-start+1)
}
return body, nil
}
// Non-206 response: capture a snippet for diagnostics, then either
// retry (transient 5xx) or fail fast.
body, _ := io.ReadAll(io.LimitReader(resp.Body, 4*1024))
_ = resp.Body.Close()
if resp.StatusCode >= 500 && resp.StatusCode < 600 && attempt < maxTransientRetries {
lastErr = fmt.Errorf("range status %d body=%q", resp.StatusCode, strings.TrimSpace(string(body)))
continue
}
if resp.StatusCode >= 200 && resp.StatusCode < 300 && end-start+1 == int64(len(body)) {
// Server ignored Range and returned a 200 with exactly the bytes
// we wanted — fine for the last chunk of a file, slightly off for
// non-tail chunks. Caller decides; we return what we got.
return body, nil
}
return nil, fmt.Errorf("range request status=%d body=%q", resp.StatusCode, strings.TrimSpace(string(body)))
}
if lastErr == nil {
lastErr = errors.New("range chunk retries exhausted")
}
return nil, fmt.Errorf("range chunk retries exhausted: %w", lastErr)
}View on GitHub (pinned to 4000b2338a)
Solutions
- Retry the download later; 5xx are retried automatically up to maxTransientRetries, so exhaustion implies a sustained outage
- Inspect the included body snippet for a Feishu error code or maintenance notice
- Check Feishu service status page for ongoing incidents
- Add exponential backoff around the whole download rather than tighter loops
Defensive patterns
Strategy: retry
Validate before calling
// check Feishu API health before bulk downloads
resp, err := http.Get("https://open.feishu.cn/")
if err != nil || resp.StatusCode >= 500 { /* defer the download */ } Try / catch
if err := downloadResource(fileToken); err != nil && strings.Contains(err.Error(), "range status 5") {
// 5xx from Feishu: back off and retry later
time.Sleep(time.Minute)
return downloadResource(fileToken)
} Prevention
- Schedule bulk downloads outside known maintenance windows
- Subscribe to Feishu/Open Platform status notifications
- Use exponential backoff around whole-download operations
- Don't hammer retries when the body snippet indicates a service incident
When it happens
Trigger: resourceFetchRemainingChunks -> resourceRangeChunk: the ranged GET returns 5xx (e.g. 500/502/503/504) more than maxTransientRetries times, or a non-retryable non-206 status reaches the final error path with this message as lastErr.
Common situations: Feishu API outage or maintenance window; rate limiting manifesting as 5xx; gateway/load-balancer errors on large Range requests; transient upstream failures during sustained chunked downloads.
Understand the failure class
Background: "API error: {status}" and "HTTP 401/403/404/429/5xx" errors: non-2xx HTTP responses explained — this error's family across 27 libraries.
Related errors
- range request: %w
- %s: CDN upload server error: %s
- too many redirects
- range chunk retries exhausted
- reasonix: POST %s returned %d: %s
AI-assisted analysis of chenhg5/cc-connect@4000b2338a (2026-09-06).
Data as JSON: /api/errors/634c6458e12b0522.
Report an issue: GitHub.