{"record":{"id":"c8f3716fddc7fc32","repo":"larksuite/cli","slug":"unsupported-content-range-q","errorCode":null,"errorMessage":"unsupported content-range: %q","messagePattern":"unsupported content-range: %q","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"extension/download/download.go","lineNumber":679,"sourceCode":"\ttotal int64\n}\n\nfunc (cr contentRange) String() string {\n\treturn fmt.Sprintf(\"bytes %d-%d/%d\", cr.start, cr.end, cr.total)\n}\n\nfunc (cr contentRange) length() int64 {\n\treturn cr.end - cr.start + 1\n}\n\nfunc parseContentRange(header string) (contentRange, error) {\n\theader = strings.TrimSpace(header)\n\tif header == \"\" {\n\t\treturn contentRange{}, fmt.Errorf(\"content-range is empty\")\n\t}\n\tunit, spec, found := strings.Cut(header, \" \")\n\tif !found || !strings.EqualFold(unit, \"bytes\") {\n\t\treturn contentRange{}, fmt.Errorf(\"unsupported content-range: %q\", header)\n\t}\n\tparts := strings.SplitN(strings.TrimSpace(spec), \"/\", 2)\n\tif len(parts) != 2 || parts[0] == \"\" || parts[1] == \"\" || parts[0] == \"*\" {\n\t\treturn contentRange{}, fmt.Errorf(\"unsupported content-range: %q\", header)\n\t}\n\tif parts[1] == \"*\" {\n\t\treturn contentRange{}, fmt.Errorf(\"unknown total size in content-range: %q\", header)\n\t}\n\tbounds := strings.SplitN(parts[0], \"-\", 2)\n\tif len(bounds) != 2 || bounds[0] == \"\" || bounds[1] == \"\" {\n\t\treturn contentRange{}, fmt.Errorf(\"unsupported content-range: %q\", header)\n\t}\n\tstart, err := strconv.ParseInt(bounds[0], 10, 64)\n\tif err != nil {\n\t\treturn contentRange{}, fmt.Errorf(\"parse range start: %w\", err)\n\t}\n\tend, err := strconv.ParseInt(bounds[1], 10, 64)\n\tif err != nil {","sourceCodeStart":661,"sourceCodeEnd":697,"githubUrl":"https://github.com/larksuite/cli/blob/7fd6ef3c07182257ce776cdc5a614e122d5bd4b3/extension/download/download.go#L661-L697","documentation":"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.","triggerScenarios":"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').","commonSituations":"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.","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."],"exampleFix":"// before (server sends)\n// Content-Range: items 0-9/50\n// after (required by this library)\n// Content-Range: bytes 0-9/50","handlingStrategy":"validation","validationCode":"func validContentRange(h string) bool {\n\tunit, spec, ok := strings.Cut(h, \" \")\n\treturn ok && strings.EqualFold(unit, \"bytes\") && strings.Contains(spec, \"/\")\n}\n// check resp.Header.Get(\"Content-Range\") before resuming","typeGuard":null,"tryCatchPattern":"cr, err := parseContentRange(header)\nif err != nil {\n\treturn fmt.Errorf(\"server sent non-bytes Content-Range %q: %w\", header, err)\n}","preventionTips":["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"],"tags":["http","content-range","download"],"backgroundTag":"invalid-content-range-header","analyzedSha":"7fd6ef3c07182257ce776cdc5a614e122d5bd4b3","analyzedAt":"2026-09-04T21:17:44.649Z","contentChangedAt":"2026-09-04T21:17:44.649Z","schemaVersion":2},"datasetVersion":"2026-09-12T02:17:10.037Z"}