{"record":{"id":"0c284943836df12f","repo":"larksuite/cli","slug":"parse-range-end-w","errorCode":null,"errorMessage":"parse range end: %w","messagePattern":"parse range end: %w","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"extension/download/download.go","lineNumber":698,"sourceCode":"\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 {\n\t\treturn contentRange{}, fmt.Errorf(\"parse range end: %w\", err)\n\t}\n\ttotal, err := strconv.ParseInt(parts[1], 10, 64)\n\tif err != nil {\n\t\treturn contentRange{}, fmt.Errorf(\"parse total size: %w\", err)\n\t}\n\tif total <= 0 {\n\t\treturn contentRange{}, fmt.Errorf(\"invalid total size: %d\", total)\n\t}\n\tif start < 0 || end < 0 {\n\t\treturn contentRange{}, fmt.Errorf(\"invalid negative content range: %d-%d\", start, end)\n\t}\n\tif start > end {\n\t\treturn contentRange{}, fmt.Errorf(\"invalid content range: start %d is after end %d\", start, end)\n\t}\n\tif end >= total {\n\t\treturn contentRange{}, fmt.Errorf(\"invalid content range: end %d is outside total %d\", end, total)\n\t}\n\treturn contentRange{start: start, end: end, total: total}, nil","sourceCodeStart":680,"sourceCodeEnd":716,"githubUrl":"https://github.com/larksuite/cli/blob/7fd6ef3c07182257ce776cdc5a614e122d5bd4b3/extension/download/download.go#L680-L716","documentation":"parseContentRange validated the range start but the end bound of `bytes start-end/total` failed strconv.ParseInt; the wrapped error is strconv's. The server's Content-Range header has a non-integer end value for the partial response.","triggerScenarios":"openPartial or openNext received something like 'bytes 0-nine/500' or an end value beyond int64.","commonSituations":"Buggy or malicious servers; proxies that inject characters; hand-written mock responses with placeholder text.","solutions":["Inspect raw headers to see the exact malformed value.","Fix the server/proxy generating the header.","Validate the endpoint with curl -r 0-99 -D- URL.","Avoid third-party middleboxes that rewrite response headers."],"exampleFix":"// before\n// Content-Range: bytes 0-nine/500\n// after\n// Content-Range: bytes 0-499/500","handlingStrategy":"try-catch","validationCode":"func numericEnd(h string) bool {\n\t_, spec, _ := strings.Cut(h, \" \")\n\tstartEnd, _, _ := strings.Cut(spec, \"/\")\n\t_, end, _ := strings.Cut(startEnd, \"-\")\n\t_, err := strconv.ParseInt(end, 10, 64)\n\treturn err == nil\n}","typeGuard":null,"tryCatchPattern":"cr, err := parseContentRange(header)\nif err != nil {\n\treturn fmt.Errorf(\"malformed Content-Range end in %q: %w\", header, err)\n}","preventionTips":["Inspect headers with curl -D- when a download stalls","Avoid rewriting proxies between client and storage","Use well-tested HTTP servers/CDNs for range support"],"tags":["http","content-range","download","parsing"],"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"}