{"record":{"id":"3c5e01abc4e1b9bb","repo":"AlistGo/alist","slug":"invalid-range-3c5e01","errorCode":null,"errorMessage":"invalid range","messagePattern":"invalid range","errorType":"http","errorClass":null,"httpStatus":416,"severity":"error","filePath":"internal/net/serve.go","lineNumber":105,"sourceCode":"\t// handle Content-Range header.\n\tsendSize := size\n\tvar sendContent io.ReadCloser\n\tranges, err := http_range.ParseRange(rangeReq, size)\n\tswitch {\n\tcase err == nil:\n\tcase errors.Is(err, http_range.ErrNoOverlap):\n\t\tif size == 0 {\n\t\t\t// Some clients add a Range header to all requests to\n\t\t\t// limit the size of the response. If the file is empty,\n\t\t\t// ignore the range header and respond with a 200 rather\n\t\t\t// than a 416.\n\t\t\tranges = nil\n\t\t\tbreak\n\t\t}\n\t\tw.Header().Set(\"Content-Range\", fmt.Sprintf(\"bytes */%d\", size))\n\t\tfallthrough\n\tdefault:\n\t\thttp.Error(w, err.Error(), http.StatusRequestedRangeNotSatisfiable)\n\t\treturn nil\n\t}\n\n\tif sumRangesSize(ranges) > size {\n\t\t// The total number of bytes in all the ranges is larger than the size of the file\n\t\t// or unknown file size, ignore the range request.\n\t\tranges = nil\n\t}\n\n\t// 使用请求的Context\n\t// 不然从sendContent读不到数据，即使请求断开CopyBuffer也会一直堵塞\n\tctx := context.WithValue(r.Context(), \"request_header\", r.Header)\n\tswitch {\n\tcase len(ranges) == 0:\n\t\treader, err := RangeReadCloser.RangeRead(ctx, http_range.Range{Length: -1})\n\t\tif err != nil {\n\t\t\tcode = http.StatusRequestedRangeNotSatisfiable\n\t\t\tif err == ErrExceedMaxConcurrency {","sourceCodeStart":87,"sourceCodeEnd":123,"githubUrl":"https://github.com/AlistGo/alist/blob/843d9dc8149126976b2625911e45a4d3ffd6f2f5/internal/net/serve.go#L87-L123","documentation":"Error \"invalid range\" thrown in AlistGo/alist.","triggerScenarios":"Thrown at internal/net/serve.go:105 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Send a valid HTTP Range header within the file size bounds and retry the request."],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"843d9dc8149126976b2625911e45a4d3ffd6f2f5","analyzedAt":"2026-08-15T12:14:11.722Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}