{"record":{"id":"264c9d12a9e7755f","repo":"elastic/elasticsearch","slug":"failed-to-set-the-keystore-password-for","errorCode":null,"errorMessage":"Failed to set the keystore password for {}","messagePattern":"Failed to set the keystore password for (.+?)","errorType":"exception","errorClass":"TestClustersException","httpStatus":null,"severity":"error","filePath":"build-tools/src/main/java/org/elasticsearch/gradle/testclusters/ElasticsearchNode.java","lineNumber":932,"sourceCode":"        processBuilder.directory(workingDir.toFile());\n        Map<String, String> environment = processBuilder.environment();\n        // Don't inherit anything from the environment for as that would lack reproducibility\n        environment.clear();\n        environment.putAll(getESEnvironment());\n        String cliJvmArgsString = String.join(\" \", cliJvmArgs);\n        environment.put(\"CLI_JAVA_OPTS\", cliJvmArgsString + \" \" + System.getProperty(\"tests.jvm.argline\", \"\"));\n\n        // Direct the stderr to the ES log file. This should capture any jvm problems to start.\n        // Stdout is discarded because ES duplicates the log file to stdout when run in the foreground.\n        processBuilder.redirectOutput(ProcessBuilder.Redirect.appendTo(esOutputFile.toFile()));\n        processBuilder.redirectErrorStream(true);\n\n        if (keystorePassword != null && keystorePassword.length() > 0) {\n            try {\n                Files.writeString(esInputFile, keystorePassword + \"\\n\", StandardOpenOption.CREATE);\n                processBuilder.redirectInput(esInputFile.toFile());\n            } catch (IOException e) {\n                throw new TestClustersException(\"Failed to set the keystore password for \" + this, e);\n            }\n        }\n        LOGGER.info(\"Running `{}` in `{}` for {} env: {}\", command, workingDir, this, environment);\n        Process esProcess;\n        try {\n            esProcess = processBuilder.start();\n        } catch (IOException e) {\n            throw new TestClustersException(\"Failed to start ES process for \" + this, e);\n        }\n        testClustersRegistryProvider.get().storeProcess(id(), esProcess);\n        reaperServiceProvider.get().registerPid(toString(), esProcess.pid());\n    }\n\n    @Internal\n    public Path getDistroDir() {\n        return canUseSharedDistribution()\n            ? getExtractedDistributionDir().toFile().listFiles()[0].toPath()\n            : workingDir.resolve(\"distro\").resolve(getVersion() + \"-\" + testDistribution);","sourceCodeStart":914,"sourceCodeEnd":950,"githubUrl":"https://github.com/elastic/elasticsearch/blob/db6a809a667c081ca1dc7500389d26975573215f/build-tools/src/main/java/org/elasticsearch/gradle/testclusters/ElasticsearchNode.java#L914-L950","documentation":"Thrown by startElasticsearchProcess() when Files.writeString(esInputFile, keystorePassword+'\\n', CREATE) raises an IOException, wrapped as TestClustersException with the node identity. The code writes the keystore password to a temp file so it can be fed to the ES process via processBuilder.redirectInput; failing to materialise that file means the secured keystore cannot be unlocked at boot.","triggerScenarios":"A non-empty keystorePassword is configured, and writing it to esInputFile fails: parent dir missing/ read-only, disk full, permission residue, path-too-long, or antivirus interference. The check fires at process launch time inside start().","commonSituations":"Disk full on CI agent. Permission residue from a root-owned prior run. Windows MAX_PATH in the esInputFile path. Antivirus locking temp files. Stale build/testclusters after a host change.","solutions":["Read the cause IOException for the precise FS error (message vs permission vs space).","Clean build/testclusters/<node> so esInputFile and its parent are recreated.","Free disk / inodes and fix ownership on the build dir.","Shorten the build path on Windows to avoid MAX_PATH for the input file."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// Confirm the esInputFile parent is writable before start\nPath inputParent = node.getEsInputFile().getParent();\nif (Files.exists(inputParent) && !Files.isWritable(inputParent)) {\n    throw new IllegalStateException(\"esInputFile dir not writable: \" + inputParent);\n}\nif (node.getKeystorePassword() != null && node.getKeystorePassword().length() > 0\n        && OS.current() == OS.WINDOWS && node.getEsInputFile().toString().length() > 240) {\n    throw new IllegalStateException(\"esInputFile path too long for Windows: \" + node.getEsInputFile());\n}","typeGuard":null,"tryCatchPattern":"try {\n    node.start();\n} catch (TestClustersException e) {\n    if (e.getMessage() != null && e.getMessage().startsWith(\"Failed to set the keystore password\")) {\n        throw new IllegalStateException(\"Keystore password file write failed (disk/perms/path): \"\n            + e.getCause(), e);\n    }\n    throw e;\n}","preventionTips":["Keep build/testclusters paths short, especially on Windows.","Maintain consistent ownership of build/ across runs.","Free disk before secured-cluster test runs."],"tags":["testclusters","keystore","security","io","startup"],"backgroundTag":null,"analyzedSha":"db6a809a667c081ca1dc7500389d26975573215f","analyzedAt":"2026-08-12T01:39:14.192Z","schemaVersion":2},"datasetVersion":"2026-08-13T09:17:06.757Z"}