larksuite/cli · error
unsupported content-range: %q
Error message
unsupported content-range: %q
What it means
parseContentRange validates an HTTP Content-Range header returned by the server during a partial (resumable) download. This error means the header did not start with a 'bytes' unit token (case-insensitive), so the range specification could not be interpreted. The library only supports the standard 'bytes' unit defined by RFC 7233.
Source
Thrown at extension/download/download.go:679
total int64
}
func (cr contentRange) String() string {
return fmt.Sprintf("bytes %d-%d/%d", cr.start, cr.end, cr.total)
}
func (cr contentRange) length() int64 {
return cr.end - cr.start + 1
}
func parseContentRange(header string) (contentRange, error) {
header = strings.TrimSpace(header)
if header == "" {
return contentRange{}, fmt.Errorf("content-range is empty")
}
unit, spec, found := strings.Cut(header, " ")
if !found || !strings.EqualFold(unit, "bytes") {
return contentRange{}, fmt.Errorf("unsupported content-range: %q", header)
}
parts := strings.SplitN(strings.TrimSpace(spec), "/", 2)
if len(parts) != 2 || parts[0] == "" || parts[1] == "" || parts[0] == "*" {
return contentRange{}, fmt.Errorf("unsupported content-range: %q", header)
}
if parts[1] == "*" {
return contentRange{}, fmt.Errorf("unknown total size in content-range: %q", header)
}
bounds := strings.SplitN(parts[0], "-", 2)
if len(bounds) != 2 || bounds[0] == "" || bounds[1] == "" {
return contentRange{}, fmt.Errorf("unsupported content-range: %q", header)
}
start, err := strconv.ParseInt(bounds[0], 10, 64)
if err != nil {
return contentRange{}, fmt.Errorf("parse range start: %w", err)
}
end, err := strconv.ParseInt(bounds[1], 10, 64)
if err != nil {View on GitHub (pinned to 7fd6ef3c07)
Solutions
- Inspect the raw Content-Range header the server returns (curl -I or a debug proxy) and confirm it begins with 'bytes '.
- Fix or remove the proxy/CDN layer that is rewriting the header.
- If the server genuinely uses a non-bytes unit, download the resource without range requests (single full GET) instead of the partial-download path.
- Update the library/endpoint configuration so downloads go to a compliant endpoint.
Example fix
// before (server sends) // Content-Range: items 0-9/50 // after (required by this library) // Content-Range: bytes 0-9/50
Defensive patterns
Strategy: validation
Validate before calling
func validContentRange(h string) bool {
unit, spec, ok := strings.Cut(h, " ")
return ok && strings.EqualFold(unit, "bytes") && strings.Contains(spec, "/")
}
// check resp.Header.Get("Content-Range") before resuming Try / catch
cr, err := parseContentRange(header)
if err != nil {
return fmt.Errorf("server sent non-bytes Content-Range %q: %w", header, err)
} Prevention
- Test the endpoint with curl -r 0-0 -D- and verify a 'bytes ...' Content-Range before relying on partial downloads
- Avoid proxies/CDNs that rewrite response headers
- Pin downloads to endpoints known to support RFC 7233 byte ranges
When it happens
Trigger: openPartial or openNext received a 206/multi-range response whose Content-Range header is missing the 'bytes ' prefix, uses another unit like 'items 0-9/50', or has no space separator at all (e.g. 'bytes0-99/100').
Common situations: A proxy or CDN rewrites or strips the Content-Range unit; a non-Lark storage endpoint behind a custom base URL returns ranges in a non-byte unit; a broken/misbehaving server sends a malformed header with no space after the unit.
Related errors
- unknown total size in content-range: %q
- parse range start: %w
- parse range end: %w
- parse total size: %w
- invalid total size: %d
AI-assisted analysis of larksuite/cli@7fd6ef3c07 (2026-09-04).
Data as JSON: /api/errors/c8f3716fddc7fc32.
Report an issue: GitHub.