{"record":{"id":"a17a748c366e7d3d","repo":"larksuite/cli","slug":"invalid-negative-content-range-d-d","errorCode":null,"errorMessage":"invalid negative content range: %d-%d","messagePattern":"invalid negative content range: (.+?)-(.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"extension/download/download.go","lineNumber":708,"sourceCode":"\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) {\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] != '\"' {","sourceCodeStart":690,"sourceCodeEnd":726,"githubUrl":"https://github.com/larksuite/cli/blob/7fd6ef3c07182257ce776cdc5a614e122d5bd4b3/extension/download/download.go#L690-L726","documentation":"The parsed start or end offset of the Content-Range was negative, which is invalid for the 'start-end/total' inclusive form this library requires (it does not implement suffix ranges like 'bytes -100/500').","triggerScenarios":"openPartial or openNext received e.g. 'bytes -1-99/500' or 'bytes 0--1/500'.","commonSituations":"Server or proxy emitting suffix-range syntax with a stray dash; corrupted headers; test fixtures with negative values.","solutions":["Confirm the server emits 'bytes start-end/total' with non-negative offsets.","Fix middleware that mangles the range syntax.","If you need suffix ranges, fetch the full resource instead of the partial path.","Retry the request in case of transient corruption."],"exampleFix":"// before\n// Content-Range: bytes -1-99/500\n// after\n// Content-Range: bytes 0-99/500","handlingStrategy":"validation","validationCode":"func nonNegativeRange(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 >= 0 && end >= 0\n}","typeGuard":null,"tryCatchPattern":"cr, err := parseContentRange(header)\nif err != nil {\n\treturn fmt.Errorf(\"server sent negative offsets in %q: %w\", header, err)\n}","preventionTips":["Only send plain 'bytes start-end' Range requests, never suffix 'bytes=-N'","Check server/proxy header integrity before resumable downloads","Use RFC 7233-compliant endpoints"],"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"}