{"record":{"id":"b702be47aa99a2a8","repo":"apache/druid","slug":"requested-to-skip-s-bytes-but-actual-number-of","errorCode":null,"errorMessage":"Requested to skip [%s] bytes, but actual number of bytes skipped is [%s]","messagePattern":"Requested to skip \\[(.+?)\\] bytes, but actual number of bytes skipped is \\[(.+?)\\]","errorType":"exception","errorClass":"IllegalStateException","httpStatus":null,"severity":"error","filePath":"processing/src/main/java/org/apache/druid/data/input/impl/HttpEntity.java","lineNumber":123,"sourceCode":"    urlConnection.addRequestProperty(HttpHeaders.RANGE, StringUtils.format(\"bytes=%d-\", offset));\n    final String contentRange = urlConnection.getHeaderField(HttpHeaders.CONTENT_RANGE);\n    final boolean withContentRange = contentRange != null && contentRange.startsWith(\"bytes \");\n    if (withContentRange && offset > 0) {\n      return urlConnection.getInputStream();\n    } else {\n      if (!withContentRange && offset > 0) {\n        LOG.warn(\n            \"Since the input source doesn't support range requests, the object input stream is opened from the start and \"\n            + \"then skipped. This may make the ingestion speed slower. Consider enabling prefetch if you see this message\"\n            + \" a lot.\"\n        );\n      }\n      InputStream in = urlConnection.getInputStream();\n      try {\n        final long skipped = in.skip(offset);\n        if (skipped != offset) {\n          in.close();\n          throw new ISE(\"Requested to skip [%s] bytes, but actual number of bytes skipped is [%s]\", offset, skipped);\n        } else {\n          return in;\n        }\n      }\n      catch (IOException ex) {\n        in.close();\n        throw ex;\n      }\n    }\n  }\n}\n","sourceCodeStart":105,"sourceCodeEnd":135,"githubUrl":"https://github.com/apache/druid/blob/9b90983fd291f26935af934383ce360473179e4d/processing/src/main/java/org/apache/druid/data/input/impl/HttpEntity.java#L105-L135","documentation":"HttpEntity.openInputStream calls InputStream.skip(offset) to seek to the byte offset of a split within an HTTP response, and verifies the stream actually skipped the requested number of bytes. HTTP streams are not guaranteed to honor skip, so when fewer bytes are skipped the entity closes the stream and fails the split instead of silently reading misaligned data.","triggerScenarios":"Reading a range/offset of an HTTP-served file where the server (or a proxy) does not support byte ranges and returns the body from byte 0, or terminates/truncates the response so skip() advances fewer than 'offset' bytes.","commonSituations":"Servers or CDNs ignoring the Range header; compressed (gzip) responses where skip cannot jump ahead; flaky proxies cutting responses short; very large offsets on keep-alive connections that reset.","solutions":["Ensure the HTTP server supports Range requests (Accept-Ranges: bytes) and serves the file uncompressed","Retry the split; transient truncation often succeeds on a second attempt","Serve the data over a range-capable source (S3 with Range support, HDFS, local files) instead of a non-compliant HTTP endpoint","Disable compression for this endpoint or use Content-Length-aligned static file serving"],"exampleFix":null,"handlingStrategy":"retry","validationCode":"// Before relying on offsets, verify the endpoint supports ranges\nHttpURLConnection c = (HttpURLConnection) new URI(uri).toURL().openConnection();\nc.setRequestMethod(\"HEAD\");\nboolean rangeOk = \"bytes\".equalsIgnoreCase(c.getHeaderField(\"Accept-Ranges\"));","typeGuard":null,"tryCatchPattern":"try { return entity.open(); } catch (ISE e) { if (e.getMessage().startsWith(\"Requested to skip\")) { /* re-queue split or switch to range-capable source */ } throw e; }","preventionTips":["Serve split-readable data only from servers supporting Accept-Ranges: bytes","Disable gzip for machine-to-machine data endpoints","Prefer S3/HDFS/local input sources for large files over generic HTTP"],"tags":["http","network","input-source"],"backgroundTag":"http-request-failed","analyzedSha":"9b90983fd291f26935af934383ce360473179e4d","analyzedAt":"2026-09-07T13:32:30.957Z","contentChangedAt":"2026-09-07T13:32:30.957Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}