{"record":{"id":"87725ca92fa6dd69","repo":"apache/druid","slug":"cannot-list-directory-s-87725c","errorCode":null,"errorMessage":"Cannot list directory [%s]","messagePattern":"Cannot list directory \\[(.+?)\\]","errorType":"exception","errorClass":"IOException","httpStatus":null,"severity":"error","filePath":"server/src/main/java/org/apache/druid/segment/loading/LocalDataSegmentPusher.java","lineNumber":136,"sourceCode":"      }\n\n      return baseSegment.withLoadSpec(makeLoadSpec(new File(outDir, INDEX_ZIP_FILENAME).toURI()))\n                        .withSize(size);\n    }\n    finally {\n      FileUtils.deleteDirectory(tmpSegmentDir);\n    }\n  }\n\n  private DataSegment pushNoZip(final File inDir, final File outDir, final DataSegment baseSegment) throws IOException\n  {\n    final File tmpSegmentDir = new File(config.getStorageDirectory(), makeIntermediateDir());\n    FileUtils.mkdirp(tmpSegmentDir);\n\n    try {\n      final File[] files = inDir.listFiles();\n      if (files == null) {\n        throw new IOE(\"Cannot list directory [%s]\", inDir);\n      }\n\n      long size = 0;\n      for (final File file : files) {\n        if (file.isFile()) {\n          size += file.length();\n          FileUtils.linkOrCopy(file, new File(tmpSegmentDir, file.getName()));\n        } else {\n          // Segment directories are expected to be flat.\n          throw new IOE(\"Unexpected subdirectory [%s]\", file.getName());\n        }\n      }\n\n      final File segmentDir = new File(outDir, INDEX_DIR);\n      FileUtils.mkdirp(outDir);\n\n      try {\n        Files.move(tmpSegmentDir.toPath(), segmentDir.toPath(), StandardCopyOption.ATOMIC_MOVE);","sourceCodeStart":118,"sourceCodeEnd":154,"githubUrl":"https://github.com/apache/druid/blob/9b90983fd291f26935af934383ce360473179e4d/server/src/main/java/org/apache/druid/segment/loading/LocalDataSegmentPusher.java#L118-L154","documentation":"LocalDataSegmentPusher.pushNoZip throws IOException when File.listFiles() returns null on the input segment directory, meaning the directory could not be read (does not exist, is not a directory, or is unreadable). The no-zip push mode needs to enumerate all segment files to link them into storage.","triggerScenarios":"pushToPath -> pushNoZip with an inDir that is missing, is actually a file, or lacks read/execute permission; also on I/O errors from the underlying filesystem.","commonSituations":"Task output directory cleaned up before push; permissions broken after running tasks under different users; path misconfigured so a file path is passed where a directory is expected; NFS mount dropped.","solutions":["Verify inDir exists, is a directory, and is readable by the Druid user (ls -ld <dir>).","Fix filesystem permissions/ownership of the task work directory.","Check that the mount holding the segment dir is healthy (NFS/disk errors).","Re-run the ingestion task to regenerate the segment directory."],"exampleFix":"// before: dir deleted before push (aggressive cleanup job)\nfind /druid-task-work -mmin +30 -delete\n// after: retain until push completes / exclude task dirs\nfind /druid-task-work -mmin +1440 -delete","handlingStrategy":"validation","validationCode":"if (!inDir.isDirectory() || !inDir.canRead()) {\n  throw new IllegalStateException(\"segment input dir missing or unreadable: \" + inDir);\n}","typeGuard":"boolean isReadableDirectory(File dir) {\n  return dir != null && dir.isDirectory() && dir.canRead() && dir.canExecute();\n}","tryCatchPattern":"try {\n  pusher.push(segment, outDir, false);\n} catch (IOException e) {\n  log.error(e, \"cannot read segment dir %s; check permissions/mount\", inDir);\n  throw e;\n}","preventionTips":["Run all Druid services under one consistent user so work-dir permissions stay uniform.","Don't run aggressive cleanup jobs on task work directories before push completes.","Monitor NFS/disk mounts for failures before they break ingestion.","Verify segment output paths are directories, not files, in custom pipelines."],"tags":["segment-push","io","directory-not-found","local-deep-storage"],"backgroundTag":"directory-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"}