{"record":{"id":"4ee3d4429bd63e54","repo":"larksuite/cli","slug":"parse-range-start-w","errorCode":null,"errorMessage":"parse range start: %w","messagePattern":"parse range start: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"extension/download/download.go","lineNumber":694,"sourceCode":"\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 {\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}","sourceCodeStart":676,"sourceCodeEnd":712,"githubUrl":"https://github.com/larksuite/cli/blob/7fd6ef3c07182257ce776cdc5a614e122d5bd4b3/extension/download/download.go#L676-L712","documentation":"parseContentRange successfully split a `bytes start-end/total` Content-Range header into bounds, but the start bound is not a valid base-10 integer; the wrapped error is strconv's. It means the server emitted a syntactically malformed range start in a partial response.","triggerScenarios":"openPartial or openNext received something like 'bytes abc-99/500' or a start exceeding int64.","commonSituations":"Corrupted response headers from buggy servers or proxies; tests with fake header values; binary garbage injected by a misconfigured gateway.","solutions":["Dump the raw response headers and inspect the Content-Range value.","Fix or bypass the component producing the corrupted header.","Test the endpoint with curl -r 0-0 -D- to confirm a numeric start.","Retry the download; transient corruption may clear."],"exampleFix":"// before\n// Content-Range: bytes abc-99/500\n// after\n// Content-Range: bytes 0-99/500","handlingStrategy":"try-catch","validationCode":"func numericRange(h string) bool {\n\t_, spec, _ := strings.Cut(h, \" \")\n\tstartEnd, _, _ := strings.Cut(spec, \"/\")\n\tstart, _, _ := strings.Cut(startEnd, \"-\")\n\t_, err := strconv.ParseInt(start, 10, 64)\n\treturn err == nil\n}","typeGuard":null,"tryCatchPattern":"cr, err := parseContentRange(header)\nvar perr *strconv.NumError\nif errors.As(err, &perr) {\n\treturn fmt.Errorf(\"corrupt Content-Range %q: %w\", header, err)\n}","preventionTips":["Log raw response headers when downloads fail","Remove proxies that inject non-numeric characters","Retry downloads on transient corruption"],"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"}