{"record":{"id":"6bfc2d75e129eb30","repo":"larksuite/cli","slug":"parse-total-size-w","errorCode":null,"errorMessage":"parse total size: %w","messagePattern":"parse total size: %w","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"extension/download/download.go","lineNumber":702,"sourceCode":"\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\n}\n\n// strongETag returns a validator suitable for If-Range.\nfunc strongETag(header http.Header) (string, bool) {","sourceCodeStart":684,"sourceCodeEnd":720,"githubUrl":"https://github.com/larksuite/cli/blob/7fd6ef3c07182257ce776cdc5a614e122d5bd4b3/extension/download/download.go#L684-L720","documentation":"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.","triggerScenarios":"openPartial or openNext received something like 'bytes 0-99/abc' or 'bytes 0-99/99999999999999999999'.","commonSituations":"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.","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."],"exampleFix":"// before\n// Content-Range: bytes 0-99/about-100\n// after\n// Content-Range: bytes 0-99/100","handlingStrategy":"try-catch","validationCode":"func numericTotal(h string) bool {\n\t_, spec, _ := strings.Cut(h, \" \")\n\t_, total, _ := strings.Cut(spec, \"/\")\n\tn, err := strconv.ParseInt(total, 10, 64)\n\treturn err == nil && n > 0\n}","typeGuard":null,"tryCatchPattern":"cr, err := parseContentRange(header)\nif err != nil {\n\treturn fmt.Errorf(\"bad Content-Range total in %q: %w\", header, err)\n}","preventionTips":["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"],"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"}