larksuite/cli · error
unknown total size in content-range: %q
Error message
unknown total size in content-range: %q
What it means
The Content-Range header's total-size field was '*', meaning the server does not know (or will not disclose) the full resource length. Partial-download logic needs the total size to compute offsets and verify completeness, so it refuses to continue.
Source
Thrown at extension/download/download.go:686
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 {
return contentRange{}, fmt.Errorf("parse range end: %w", err)
}
total, err := strconv.ParseInt(parts[1], 10, 64)
if err != nil {
return contentRange{}, fmt.Errorf("parse total size: %w", err)
}
if total <= 0 {View on GitHub (pinned to 7fd6ef3c07)
Solutions
- Configure the storage/gateway to return the actual total size in Content-Range.
- Ensure the object has a known Content-Length on the server side.
- Download the whole resource in one request instead of using the partial/resumable path.
- Check whether the URL points at a streaming endpoint rather than a static object.
Example fix
// before // Content-Range: bytes 0-99/* // after // Content-Range: bytes 0-99/5000
Defensive patterns
Strategy: fallback
Validate before calling
func knownTotal(h string) bool {
_, spec, _ := strings.Cut(h, " ")
_, total, _ := strings.Cut(spec, "/")
return total != "*"
} Try / catch
cr, err := parseContentRange(header)
if err != nil {
// unknown total: switch to streaming full-body download
return downloadFull(ctx, url)
} Prevention
- Configure storage/gateway to always report object size
- Download static objects, not streaming endpoints, when resuming
- Check Content-Length is present before issuing Range requests
When it happens
Trigger: openPartial or openNext received 'bytes 0-99/*' from the server.
Common situations: Dynamic or chunked-encoding responses where the server cannot compute total length; some streaming gateways emit '*' totals; misconfigured storage proxies.
Related errors
- unsupported 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/ec1a5c79ef5d6ad5.
Report an issue: GitHub.