{"record":{"id":"96c38877a9fa6204","repo":"apache/druid","slug":"path-s-does-not-exist","errorCode":null,"errorMessage":"Path [%s] does not exist","messagePattern":"Path \\[(.+?)\\] does not exist","errorType":"exception","errorClass":"IllegalStateException","httpStatus":null,"severity":"error","filePath":"processing/src/main/java/org/apache/druid/java/util/common/FileUtils.java","lineNumber":487,"sourceCode":"      throw new IAE(\"Path[%s] is not within directory[%s]\", path, directory);\n    }\n    return resolvedPath.toFile();\n  }\n\n  @SuppressForbidden(reason = \"Files#createTempDirectory\")\n  public static File createTempDirInLocation(final Path parentDirectory, @Nullable final String prefix)\n  {\n    try {\n      final Path tmpPath = Files.createTempDirectory(\n          parentDirectory,\n          prefix == null || prefix.isEmpty() ? \"druid\" : prefix\n      );\n      return tmpPath.toFile();\n    }\n    catch (IOException e) {\n      // Some inspection to improve error messages.\n      if (e instanceof NoSuchFileException && !parentDirectory.toFile().exists()) {\n        throw new ISE(\"Path [%s] does not exist\", parentDirectory);\n      } else if ((e instanceof FileSystemException && e.getMessage().contains(\"Read-only file system\"))\n                 || (e instanceof AccessDeniedException)) {\n        throw new ISE(\"Path [%s] is not writable, check permissions\", parentDirectory);\n      } else {\n        // Well, maybe it was something else.\n        throw new ISE(e, \"Failed to create temporary directory in path [%s]\", parentDirectory);\n      }\n    }\n  }\n\n  /**\n   * Create \"directory\" and all intermediate directories as needed. If the directory is successfully created, or already\n   * exists, returns quietly. Otherwise, throws an IOException.\n   *\n   * Simpler to use than {@link File#mkdirs()}, and more reliable since it is safe from races where two threads try\n   * to create the same directory at the same time.\n   *\n   * The name is inspired by UNIX {@code mkdir -p}, which has the same behavior.","sourceCodeStart":469,"sourceCodeEnd":505,"githubUrl":"https://github.com/apache/druid/blob/9b90983fd291f26935af934383ce360473179e4d/processing/src/main/java/org/apache/druid/java/util/common/FileUtils.java#L469-L505","documentation":"createTempDirInLocation wraps Files.createTempDirectory failures into more informative IllegalStateExceptions. When the failure is a NoSuchFileException and the parent directory does not exist, Druid reports 'Path [%s] does not exist' so the user fixes the configured temp location.","triggerScenarios":"Calling createTempDirInLocation(parentDirectory, prefix) (or createTempDir configured with a custom java.io.tmpdir/druid.*) where the parent directory is missing, so Files.createTempDirectory throws NoSuchFileException.","commonSituations":"Configured temp directory on a mount that is not mounted/removed at runtime; typo in the configured tmp path; container where the volume was never created; tmp cleaner deleted the parent.","solutions":["Create the parent directory before starting Druid (mkdir -p) or fix the configured path","Verify the path exists and is writable at startup (add a health check)","Check mounts in containers/Kubernetes (emptyDir/hostPath actually mounted)","If the path is intentional but transient, catch ISE and retry after creating the directory"],"exampleFix":"// before\ndruid.segment.cacheLocations=/mnt/vol/tmp  # volume not mounted\n// after — ensure at startup\nFiles.createDirectories(Paths.get(\"/mnt/vol/tmp\"));","handlingStrategy":"validation","validationCode":"Path parent = Path.of(configuredTmpDir);\nif (!Files.isDirectory(parent)) {\n  Files.createDirectories(parent); // or fail fast with a clear startup error\n}","typeGuard":null,"tryCatchPattern":"try {\n  return FileUtils.createTempDir();\n} catch (IllegalStateException e) {\n  if (e.getMessage() != null && e.getMessage().contains(\"does not exist\")) {\n    Files.createDirectories(parentDir);\n    return FileUtils.createTempDir();\n  }\n  throw e;\n}","preventionTips":["Verify configured temp paths exist and are writable during service startup","Ensure volumes are mounted before the process starts in containers","Watch for aggressive tmp cleaners removing directories at runtime","Include a temp-dir writability check in health checks"],"tags":["temp-directory","io","configuration"],"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"}