{"id":"5d3e6681fa7a0853","repo":"gofiber/fiber","slug":"range-unsatisfiable-range","errorCode":null,"errorMessage":"range: unsatisfiable range","messagePattern":"range: unsatisfiable range","errorType":"http","errorClass":"ErrRangeUnsatisfiable","httpStatus":416,"severity":"warning","filePath":"error.go","lineNumber":47,"sourceCode":"\tErrRedirectBackNoFallback = NewError(StatusInternalServerError, \"Referer not found, you have to enter fallback URL for redirection.\")\n)\n\n// Range errors\nvar (\n\t// ErrRangeMalformed is returned for a syntactically invalid Range header,\n\t// which RFC 9110 Section 14.2 allows a server to reject; it carries a\n\t// 400 Bad Request status so propagating it does not surface as a 500.\n\tErrRangeMalformed = NewError(StatusBadRequest, \"range: malformed range header string\")\n\t// ErrRangeUnsupported is returned for a Range header whose range unit is\n\t// not \"bytes\". RFC 9110 Section 14.2 requires an origin server to IGNORE\n\t// a Range header field with a range unit it does not understand, so\n\t// callers receiving this error should serve the full representation\n\t// instead of returning an error response. It still carries a\n\t// 400 Bad Request status as a safety net, so blind propagation does not\n\t// surface as a 500.\n\tErrRangeUnsupported   = NewError(StatusBadRequest, \"range: unsupported range unit\")\n\tErrRangeTooLarge      = NewError(StatusRequestedRangeNotSatisfiable, \"range: too many ranges\")\n\tErrRangeUnsatisfiable = errors.New(\"range: unsatisfiable range\")\n)\n\n// Binder errors\nvar ErrCustomBinderNotFound = errors.New(\"binder: custom binder not found, please be sure to enter the right name\")\n\n// Format errors\nvar (\n\t// ErrNoHandlers is returned when c.Format is called with no arguments.\n\tErrNoHandlers = errors.New(\"format: at least one handler is required, but none were set\")\n)\n\n// gofiber/schema errors\ntype (\n\t// ConversionError Conversion error exposes the internal schema.ConversionError for public use.\n\tConversionError = schema.ConversionError\n\t// UnknownKeyError error exposes the internal schema.UnknownKeyError for public use.\n\tUnknownKeyError = schema.UnknownKeyError\n\t// EmptyFieldError error exposes the internal schema.EmptyFieldError for public use.","sourceCodeStart":29,"sourceCodeEnd":65,"githubUrl":"https://github.com/gofiber/fiber/blob/9a4c7e57fe0b080a04235d28a4b0d2b4b353d58c/error.go#L29-L65","documentation":"ErrRangeUnsatisfiable (error.go:47) is the sentinel for an HTTP Range request whose byte ranges cannot be satisfied against the current resource (e.g. a start position past the end of the content, or a reversed range). Unlike the 400-carrying ErrRangeMalformed, this is a pure plain error (no embedded status) intended for the 416 Requested Range Not Satisfiable response path, distinct from malformed-syntax (400) cases.","triggerScenarios":"A client sends 'Range: bytes=1000-2000' for a 500-byte body, or 'bytes=10-5' (reversed), or a suffix/last-byte start beyond content length. The Range parser produces an unsatisfiable result and the handler returns this error to drive a 416 response.","commonSituations":"Clients (download managers, media players) computing ranges from stale Content-Length, proxies rewriting ranges incorrectly, or handlers serving variable-length content where the client's cached length is wrong.","solutions":["Respond with 416 Range Not Satisfiable and a Content-Range header showing the actual total length.","If full-content fallback is acceptable, ignore the Range header and serve the complete representation.","Validate that the requested start is within content bounds before applying the range."],"exampleFix":"// before\nif err := c.SendFile(\"report.pdf\"); err != nil {\n    return err // surfaces ErrRangeUnsatisfiable to the default error handler\n}\n\n// after\nif err := c.SendFile(\"report.pdf\"); err != nil {\n    if errors.Is(err, fiber.ErrRangeUnsatisfiable) {\n        return c.Status(fiber.StatusRequestedRangeNotSatisfiable).\n            Set(\"Content-Range\", \"bytes */\"+strconv.Itoa(size)).SendString(\"range not satisfiable\")\n    }\n    return err\n}","handlingStrategy":"try-catch","validationCode":"// Optionally fall back to full content when a range is unsatisfiable.\n// (Validation is at response time; pre-check start against known size.)\nif r := c.Get(fiber.HeaderRange); r != \"\" {\n    if start, _ := parseRangeStart(r); start >= contentSize {\n        c.Response().Header.Del(fiber.HeaderAcceptRanges)\n    }\n}","typeGuard":null,"tryCatchPattern":"if err := c.SendFile(path); err != nil {\n    if errors.Is(err, fiber.ErrRangeUnsatisfiable) {\n        return c.Status(fiber.StatusRequestedRangeNotSatisfiable).\n            Set(\"Content-Range\", fmt.Sprintf(\"bytes */%d\", size)).\n            SendString(\"range not satisfiable\")\n    }\n    return err\n}","preventionTips":["Always respond to unsatisfiable ranges with 416 and a Content-Range showing total size.","Consider serving the full representation when range support is optional.","Validate requested start offsets against known content length before applying."],"tags":["http","range","download","client-error","fiber"],"analyzedSha":"9a4c7e57fe0b080a04235d28a4b0d2b4b353d58c","analyzedAt":"2026-08-04T21:44:03.395Z","schemaVersion":2}