{"record":{"id":"ed44c3c4641daf0d","repo":"larksuite/cli","slug":"invalid-content-range-start-d-is-after-end-d","errorCode":null,"errorMessage":"invalid content range: start %d is after end %d","messagePattern":"invalid content range: start (.+?) is after end (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"extension/download/download.go","lineNumber":711,"sourceCode":"\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) {\n\tvalues := header.Values(\"ETag\")\n\tif len(values) != 1 {\n\t\treturn \"\", false\n\t}\n\ttag := strings.TrimSpace(values[0])\n\tif len(tag) < 2 || tag[0] != '\"' || tag[len(tag)-1] != '\"' {\n\t\treturn \"\", false\n\t}\n\tfor i := 1; i < len(tag)-1; i++ {","sourceCodeStart":693,"sourceCodeEnd":729,"githubUrl":"https://github.com/larksuite/cli/blob/7fd6ef3c07182257ce776cdc5a614e122d5bd4b3/extension/download/download.go#L693-L729","documentation":"parseContentRange validated all numeric fields of a Content-Range header and found start > end - an unsatisfiable or bogus range from the server. Earlier checks already rejected negatives and non-integers, so both values are well-formed non-negative integers in the wrong order.","triggerScenarios":"openPartial or openNext received e.g. 'bytes 200-100/500'.","commonSituations":"Buggy server implementations swapping offsets; proxies or caching layers corrupting range values; logic errors in mock/test servers.","solutions":["Inspect raw headers and confirm whether the server really sent an inverted range.","Fix the server/proxy producing the swapped offsets.","Retry the download to rule out corruption.","If the endpoint is unreliable, use a single full GET instead of partial downloads."],"exampleFix":"// before\n// Content-Range: bytes 200-100/500\n// after\n// Content-Range: bytes 100-200/500","handlingStrategy":"retry","validationCode":"func orderedRange(h string) bool {\n\t_, spec, _ := strings.Cut(h, \" \")\n\tstartEnd, _, _ := strings.Cut(spec, \"/\")\n\ts, e, _ := strings.Cut(startEnd, \"-\")\n\tstart, err1 := strconv.ParseInt(s, 10, 64)\n\tend, err2 := strconv.ParseInt(e, 10, 64)\n\treturn err1 == nil && err2 == nil && start <= end\n}","typeGuard":null,"tryCatchPattern":"cr, err := parseContentRange(header)\nif err != nil {\n\t// inverted range is likely transient corruption: retry once, then fall back\n\tif retry < maxRetries { return retryDownload(ctx, url, retry+1) }\n\treturn downloadFull(ctx, url)\n}","preventionTips":["Retry downloads on header inconsistency; it is often transient","Inspect raw headers after repeated failures to identify the offending hop","Prefer reputable storage endpoints for partial downloads"],"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"}