{"record":{"id":"4d0e8de68e6e30a9","repo":"apache/druid","slug":"failed-to-stream-log-for-task-s","errorCode":null,"errorMessage":"Failed to stream log for task %s","messagePattern":"Failed to stream log for task (.+?)","errorType":"http","errorClass":null,"httpStatus":500,"severity":"error","filePath":"indexing-service/src/main/java/org/apache/druid/indexing/overlord/http/OverlordResource.java","lineNumber":800,"sourceCode":"      @PathParam(\"taskid\") final String taskid,\n      @QueryParam(\"offset\") @DefaultValue(\"0\") final long offset\n  )\n  {\n    try {\n      final Optional<InputStream> stream = taskLogStreamer.streamTaskLog(taskid, offset);\n      if (stream.isPresent()) {\n        return Response.ok(stream.get()).build();\n      } else {\n        return Response.status(Response.Status.NOT_FOUND)\n                       .entity(\n                           \"No log was found for this task. \"\n                           + \"No logs found for this task. Ensure that the task is running and logging is configured correctly.\"\n                       )\n                       .build();\n      }\n    }\n    catch (Exception e) {\n      log.warn(e, \"Failed to stream log for task %s\", taskid);\n      return Response.status(Response.Status.INTERNAL_SERVER_ERROR).build();\n    }\n  }\n\n  @GET\n  @Path(\"/task/{taskid}/reports\")\n  @Produces(MediaType.APPLICATION_JSON)\n  @ResourceFilters(TaskResourceFilter.class)\n  public Response doGetReports(\n      @PathParam(\"taskid\") final String taskid\n  )\n  {\n    try {\n      final Optional<InputStream> stream = taskLogStreamer.streamTaskReports(taskid);\n      if (stream.isPresent()) {\n        return Response.ok(stream.get()).build();\n      } else {\n        return Response.status(Response.Status.NOT_FOUND)","sourceCodeStart":782,"sourceCodeEnd":818,"githubUrl":"https://github.com/apache/druid/blob/9b90983fd291f26935af934383ce360473179e4d/indexing-service/src/main/java/org/apache/druid/indexing/overlord/http/OverlordResource.java#L782-L818","documentation":"The Overlord's task log streaming endpoint (GET /druid/indexer/v1/task/{id}/log) hit an unexpected exception while locating or streaming the task log. It logs the exception and returns a bare HTTP 500 with no body.","triggerScenarios":"GET /druid/indexer/v1/task/{taskid}/log when the TaskRunner's streamTaskLog throws, e.g. the log file disappears mid-stream or the underlying worker lookup fails.","commonSituations":"Task logs already cleaned up by log retention; middle manager unreachable or task log file rotated while streaming; misconfigured log directory in the worker.","solutions":["Check Overlord logs for the full exception stack trace","Confirm the task exists and its log files exist on the worker (druid.indexer.logs.directory)","Retry the request; if logs were purged, re-run the task to regenerate them","If running on remote workers, ensure the worker is reachable and serving log endpoints"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// Confirm the task exists before streaming logs\n// GET /druid/indexer/v1/task/{id}/status -> 200","typeGuard":null,"tryCatchPattern":"try { streamLog(taskId); } catch (WebApplicationException e) { if (e.getResponse().getStatus() == 500) { /* fall back to reading worker log dir directly */ } }","preventionTips":["Fetch logs promptly before log retention purges them","Keep druid.indexer.logs.directory on a healthy, writable volume","Check task status before requesting logs"],"tags":["rest-api","logging","task-logs"],"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-14T11:17:12.474Z"}