{"record":{"id":"1d645396c8f1feab","repo":"apache/druid","slug":"error-occurred-while-trying-to-read-uri","errorCode":null,"errorMessage":"Error occurred while trying to read uri: ","messagePattern":"Error occurred while trying to read uri: ","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"processing/src/main/java/org/apache/druid/data/input/impl/InputEntityIteratingReader.java","lineNumber":79,"sourceCode":"    this.inputFormat = inputFormat;\n    this.sourceIterator = (CloseableIterator<InputEntity>) sourceIterator;\n    this.systemFieldDecoratorFactory = systemFieldDecoratorFactory;\n    this.temporaryDirectory = temporaryDirectory;\n  }\n\n  @Override\n  public CloseableIterator<InputRow> read(InputStats inputStats)\n  {\n    return createIterator(entity -> {\n      // InputEntityReader is stateful and so a new one should be created per entity.\n      final Function<InputRow, InputRow> systemFieldDecorator = systemFieldDecoratorFactory.decorator(entity);\n      try {\n        final InputEntity entityToRead = inputStats == null ? entity : new BytesCountingInputEntity(entity, inputStats);\n        final InputEntityReader reader = inputFormat.createReader(inputRowSchema, entityToRead, temporaryDirectory);\n        return reader.read().map(systemFieldDecorator);\n      }\n      catch (IOException e) {\n        throw new RuntimeException(entity.getUri() != null ?\n                                   \"Error occurred while trying to read uri: \" + entity.getUri() :\n                                   \"Error occurred while reading input\", e);\n      }\n    });\n  }\n\n  @Override\n  public CloseableIterator<InputRowListPlusRawValues> sample()\n  {\n    return createIterator(entity -> {\n      // InputEntityReader is stateful and so a new one should be created per entity.\n      final Function<InputRow, InputRow> systemFieldDecorator = systemFieldDecoratorFactory.decorator(entity);\n      try {\n        final InputEntityReader reader = inputFormat.createReader(inputRowSchema, entity, temporaryDirectory);\n        return reader.sample()\n            .map(i -> InputRowListPlusRawValues.ofList(i.getRawValuesList(),\n                i.getInputRows() == null\n                    ? null","sourceCodeStart":61,"sourceCodeEnd":97,"githubUrl":"https://github.com/apache/druid/blob/9b90983fd291f26935af934383ce360473179e4d/processing/src/main/java/org/apache/druid/data/input/impl/InputEntityIteratingReader.java#L61-L97","documentation":"InputEntityIteratingReader.read wraps any IOException raised while opening or streaming an InputEntity in a RuntimeException prefixed with 'Error occurred while trying to read uri: <uri>' (or a generic message when the entity has no URI). It marks the fetch of that entity as failed so the task can report the offending source.","triggerScenarios":"Any IOException from inputFormat.createReader(...).read() — unreachable host, HTTP 404/403, socket timeout, prematurely closed connection, or unreadable local file — surfaces through this wrapper in InputEntityIteratingReader.read.","commonSituations":"Expired or wrong S3/HTTP credentials; file deleted between listing and read; DNS or firewall failures from Druid middle managers; network blips during long ingestion tasks.","solutions":["Check the wrapped 'Caused by' IOException for the root cause (status code, UnknownHostException, timeout)","Verify the URI is reachable and authorized from the Druid data server (curl the URI from that host)","Retry the task — transient network errors are common; consider retries in the input source config","For HTTP sources, confirm server availability and Range/keep-alive behavior; for S3, verify credentials and object existence"],"exampleFix":null,"handlingStrategy":"retry","validationCode":"// Pre-flight check of each URI from the ingestion host\nfor (URI uri : uris) {\n    URLConnection c = uri.toURL().openConnection();\n    try (InputStream in = c.getInputStream()) { in.read(); } // throws early if unreachable\n}","typeGuard":null,"tryCatchPattern":"try { iterator.forEachRemaining(...); } catch (RuntimeException e) { if (e.getMessage().startsWith(\"Error occurred while trying to read uri:\")) { log URI; schedule retry; } else throw e; }","preventionTips":["Verify credentials/network reachability from Druid data servers, not just your workstation","Enable task retry/reports and monitor parse/fetch exception metrics","Re-check that listed objects still exist at read time (avoid listing-then-delete races)"],"tags":["io","input-source","network"],"backgroundTag":"file-read-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"}