{"record":{"id":"894d597a4f9c0153","repo":"SonarSource/sonarqube","slug":"property-s-is-not-valid-not-a-directory-s","errorCode":null,"errorMessage":"Property '%s' is not valid, not a directory: %s","messagePattern":"Property '(.+?)' is not valid, not a directory: (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"server/sonar-main/src/main/java/org/sonar/application/AppFileSystem.java","lineNumber":87,"sourceCode":"  public File getTempDir() {\n    return settings.getProps().nonNullValueAsFile(PATH_TEMP.getKey());\n  }\n\n  private boolean createDirectory(String propKey) throws IOException {\n    File dir = settings.getProps().nonNullValueAsFile(propKey);\n    if (dir.exists()) {\n      ensureIsNotAFile(propKey, dir);\n      return false;\n    }\n\n    forceMkdir(dir);\n    ensureIsNotAFile(propKey, dir);\n    return true;\n  }\n\n  private static void ensureIsNotAFile(String propKey, File dir) {\n    if (!dir.isDirectory()) {\n      throw new IllegalStateException(format(\"Property '%s' is not valid, not a directory: %s\",\n        propKey, dir.getAbsolutePath()));\n    }\n  }\n\n  private File createOrCleanTempDirectory(String propKey) throws IOException {\n    File dir = settings.getProps().nonNullValueAsFile(propKey);\n    LOG.info(\"Cleaning or creating temp directory {}\", dir.getAbsolutePath());\n    if (!createDirectory(propKey)) {\n      Files.walkFileTree(dir.toPath(), FOLLOW_LINKS, CleanTempDirFileVisitor.VISIT_MAX_DEPTH, new CleanTempDirFileVisitor(dir.toPath()));\n    }\n    return dir;\n  }\n\n  private static class CleanTempDirFileVisitor extends SimpleFileVisitor<Path> {\n    private static final Path SHAREDMEMORY_FILE = Paths.get(\"sharedmemory\");\n    static final int VISIT_MAX_DEPTH = 1;\n\n    private final Path path;","sourceCodeStart":69,"sourceCodeEnd":105,"githubUrl":"https://github.com/SonarSource/sonarqube/blob/184c821202192afc1c599fc912d0889b69fffa53/server/sonar-main/src/main/java/org/sonar/application/AppFileSystem.java#L69-L105","documentation":"AppFileSystem validates configured SonarQube directories (data, temp, etc.) before use. ensureIsNotAFile throws this IllegalStateException when a path given via a *path* property exists but is a regular file instead of a directory, since the server needs to create/clean directories at that location.","triggerScenarios":"A sonar.path.* property (e.g. sonar.path.data, sonar.path.temp, sonar.path.logs) points at an existing regular file, so dir.isDirectory() is false when createDirectory() runs during server startup.","commonSituations":"Config mistakes where a path property was set to a file (e.g. a tarball or log file) instead of a directory; a leftover file created accidentally at the expected directory path; bind-mounting a file where a directory is expected in containers.","solutions":["Inspect the property named in the message and change sonar.path.* to point to a directory (or remove it to use the default).","Move or delete the offending file so the server can create the directory there.","Check filesystem permissions/ownership so the sonarqube user can access the intended directory.","In containers/orchestrations, fix volume mounts so a directory is mounted, not a file."],"exampleFix":"// before (conf/sonar.properties)\nsonar.path.data=/opt/sonarqube/backup.tar.gz\n// after\nsonar.path.data=/opt/sonarqube/data","handlingStrategy":"validation","validationCode":"for (String key : List.of(\"sonar.path.data\", \"sonar.path.temp\", \"sonar.path.logs\", \"sonar.path.web\")) {\n    String v = props.get(key);\n    if (v != null && new File(v).exists() && !new File(v).isDirectory()) {\n        throw new IllegalStateException(key + \" must be a directory, got file: \" + v);\n    }\n}","typeGuard":null,"tryCatchPattern":"try { fileSystem.createDirectory(propKey); } catch (IllegalStateException e) { log.severe(e.getMessage()); System.exit(1); }","preventionTips":["Point sonar.path.* properties at directories, never at files.","Validate sonar.properties paths after config-management changes.","Use dedicated directories (data/, temp/, logs/) with correct ownership.","In containers, mount volumes as directories explicitly."],"tags":["filesystem","configuration","startup"],"backgroundTag":"path-is-not-a-directory","analyzedSha":"184c821202192afc1c599fc912d0889b69fffa53","analyzedAt":"2026-09-09T12:23:51.573Z","contentChangedAt":"2026-09-09T12:23:51.573Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}