{"record":{"id":"9fc39494b67a15df","repo":"apache/druid","slug":"failed-to-stream-logs-from-s","errorCode":null,"errorMessage":"Failed to stream logs from: %s","messagePattern":"Failed to stream logs from: (.+?)","errorType":"exception","errorClass":"IOE","httpStatus":null,"severity":"error","filePath":"extensions-core/azure-extensions/src/main/java/org/apache/druid/storage/azure/AzureTaskLogs.java","lineNumber":165,"sourceCode":"        if (offset > 0 && offset < length) {\n          start = offset;\n        } else if (offset < 0 && (-1 * offset) < length) {\n          start = length + offset;\n        } else {\n          start = 0;\n        }\n\n        InputStream stream = azureStorage.getBlockBlobInputStream(container, taskKey);\n        stream.skip(start);\n\n        return Optional.of(stream);\n      }\n      catch (Exception e) {\n        throw new IOException(e);\n      }\n    }\n    catch (BlobStorageException e) {\n      throw new IOE(e, \"Failed to stream logs from: %s\", taskKey);\n    }\n  }\n\n  private String getTaskLogKey(String taskid)\n  {\n    return StringUtils.format(\"%s/%s/log\", config.getPrefix(), taskid);\n  }\n\n  private String getTaskReportsKey(String taskid)\n  {\n    return StringUtils.format(\"%s/%s/report.json\", config.getPrefix(), taskid);\n  }\n\n  private String getTaskStatusKey(String taskid)\n  {\n    return StringUtils.format(\"%s/%s/status.json\", config.getPrefix(), taskid);\n  }\n","sourceCodeStart":147,"sourceCodeEnd":183,"githubUrl":"https://github.com/apache/druid/blob/9b90983fd291f26935af934383ce360473179e4d/extensions-core/azure-extensions/src/main/java/org/apache/druid/storage/azure/AzureTaskLogs.java#L147-L183","documentation":"This IOException is thrown when streamTaskFile receives a BlobStorageException while trying to stream a task file from Azure blob storage. The message includes the blob taskKey, indicating the Azure service itself returned an error (404 not found, 403 auth failure, 412 precondition, etc.) for the requested blob.","triggerScenarios":"streamTaskLog/streamTaskPayload/streamTaskReports/streamTaskStatus requests a blob whose read triggers a BlobStorageException from Azure — typically a 404 because the task log/report/status/payload was not written to container+taskKey, or 403 due to bad credentials/SAS permissions.","commonSituations":"Requesting logs for a task that never ran or whose logs were killed by killOlderThan; wrong druid.storage.prefix so the constructed taskKey does not match the uploaded blob; container or SAS token lacking read permission; region-outage 5xx errors.","solutions":["Confirm the blob exists: az storage blob list --container-name <container> --prefix <taskKey> and compare with the configured druid.storage.prefix","If 404, verify the task actually completed successfully and its logs were pushed before being requested","If 403, validate the account key / SAS token and that it grants read (and list) permissions on the container","Retry on transient 5xx status codes; Azure storage occasionally returns transient service errors"],"exampleFix":"// before (caller assumes blob exists)\nOptional<InputStream> s = taskLogs.streamTaskLog(taskId, 0);\n// after\nOptional<InputStream> s = taskLogs.streamTaskLog(taskId, 0);\nif (!s.isPresent()) {\n  log.warn(\"Task log for %s not found in Azure storage\", taskId);\n}","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try { Optional<InputStream> s = taskLogs.streamTaskLog(taskId, offset); if (!s.isPresent()) { /* blob absent: handle gracefully */ } } catch (IOException e) { log.error(\"Failed to stream task file: {}\", e.getMessage()); }","preventionTips":["Match druid.storage.prefix exactly with what the writer used; prefix mismatches are the top cause of 404s","Only stream task files after the task has completed successfully","Check blob existence (pathExists / az storage blob exists) before streaming in tooling code","Verify read permissions on the SAS token/key used by the coordinator/overlord"],"tags":["azure","blob-storage","resource-not-found","streaming"],"backgroundTag":"resource-not-found","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"}