larksuite/cli · error
parse total size: %w
Error message
parse total size: %w
What it means
parseContentRange could not parse the total-size component of a `bytes start-end/total` Content-Range header with strconv.ParseInt; the wrapped error is strconv's. Both bounds were fine, but the total reported for the partial resource is not an integer.
Source
Thrown at extension/download/download.go:702
}
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 {
return contentRange{}, fmt.Errorf("invalid total size: %d", total)
}
if start < 0 || end < 0 {
return contentRange{}, fmt.Errorf("invalid negative content range: %d-%d", start, end)
}
if start > end {
return contentRange{}, fmt.Errorf("invalid content range: start %d is after end %d", start, end)
}
if end >= total {
return contentRange{}, fmt.Errorf("invalid content range: end %d is outside total %d", end, total)
}
return contentRange{start: start, end: end, total: total}, nil
}
// strongETag returns a validator suitable for If-Range.
func strongETag(header http.Header) (string, bool) {View on GitHub (pinned to 7fd6ef3c07)
Solutions
- Check the raw Content-Range header and fix the server to emit a plain integer total.
- If the object is larger than int64 bytes, the library cannot handle it; use a different download mechanism.
- Remove or fix proxies that alter numeric headers.
- Confirm with curl -I that Content-Length and Content-Range totals agree.
Example fix
// before // Content-Range: bytes 0-99/about-100 // after // Content-Range: bytes 0-99/100
Defensive patterns
Strategy: try-catch
Validate before calling
func numericTotal(h string) bool {
_, spec, _ := strings.Cut(h, " ")
_, total, _ := strings.Cut(spec, "/")
n, err := strconv.ParseInt(total, 10, 64)
return err == nil && n > 0
} Try / catch
cr, err := parseContentRange(header)
if err != nil {
return fmt.Errorf("bad Content-Range total in %q: %w", header, err)
} Prevention
- Ensure server emits a plain integer total size
- Compare Content-Range total with Content-Length for consistency
- For objects larger than int64 bytes use a different download strategy
When it happens
Trigger: openPartial or openNext received something like 'bytes 0-99/abc' or 'bytes 0-99/99999999999999999999'.
Common situations: Server reports totals in unexpected units or with suffix text; corrupted headers via proxies; int overflow for extremely large objects reported as decimal strings beyond int64.
Related errors
- parse range start: %w
- parse range end: %w
- unsupported content-range: %q
- unknown total size in content-range: %q
- invalid total size: %d
AI-assisted analysis of larksuite/cli@7fd6ef3c07 (2026-09-04).
Data as JSON: /api/errors/6bfc2d75e129eb30.
Report an issue: GitHub.