{"record":{"id":"414358343e539582","repo":"elastic/elasticsearch","slug":"supplied-keystore-file-does-not-exist-require","errorCode":null,"errorMessage":"supplied keystore file {} does not exist, require for {}","messagePattern":"supplied keystore file (.+?) does not exist, require for (.+?)","errorType":"exception","errorClass":"TestClustersException","httpStatus":null,"severity":"error","filePath":"build-tools/src/main/java/org/elasticsearch/gradle/testclusters/ElasticsearchNode.java","lineNumber":542,"sourceCode":"        }\n\n        logToProcessStdout(\"Creating elasticsearch keystore with password set to [\" + keystorePassword + \"]\");\n        if (keystorePassword.length() > 0) {\n            runElasticsearchBinScriptWithInput(keystorePassword + \"\\n\" + keystorePassword, \"elasticsearch-keystore\", \"create\", \"-p\");\n        } else {\n            runElasticsearchBinScript(\"elasticsearch-keystore\", \"-v\", \"create\");\n        }\n\n        if (keystoreSettings.isEmpty() == false || keystoreFiles.isEmpty() == false) {\n            logToProcessStdout(\"Adding \" + keystoreSettings.size() + \" keystore settings and \" + keystoreFiles.size() + \" keystore files\");\n\n            keystoreSettings.forEach((key, value) -> runKeystoreCommandWithPassword(keystorePassword, value.toString(), \"add\", key));\n\n            for (Map.Entry<String, File> entry : keystoreFiles.entrySet()) {\n                File file = entry.getValue();\n                requireNonNull(file, \"supplied keystoreFile was null when configuring \" + this);\n                if (file.exists() == false) {\n                    throw new TestClustersException(\"supplied keystore file \" + file + \" does not exist, require for \" + this);\n                }\n                runKeystoreCommandWithPassword(keystorePassword, \"\", \"add-file\", entry.getKey(), file.getAbsolutePath());\n            }\n        }\n\n        installModules();\n\n        if (isSettingTrue(\"xpack.security.enabled\")) {\n            if (credentials.isEmpty()) {\n                user(Collections.emptyMap());\n            }\n        }\n\n        configureSecurity();\n\n        if (cliSetup.isEmpty() == false) {\n            logToProcessStdout(\"Running \" + cliSetup.size() + \" setup commands\");\n","sourceCodeStart":524,"sourceCodeEnd":560,"githubUrl":"https://github.com/elastic/elasticsearch/blob/db6a809a667c081ca1dc7500389d26975573215f/build-tools/src/main/java/org/elasticsearch/gradle/testclusters/ElasticsearchNode.java#L524-L560","documentation":"Thrown during start() after keystore files are registered but before invoking elasticsearch-keystore add-file. The code requires a non-null File (requireNonNull) AND that file.exists() is true; a missing source file aborts keystore provisioning. This protects the keystore command from being handed a nonexistent path, which would otherwise surface as an opaque CLI error.","triggerScenarios":"Calling keystoreFile(settingKey, file) with a File whose path is wrong, generated by a task that has not produced it yet, located outside the Gradle project root, or resolved relative to the wrong working directory. Because LazyPropertyMap is lazy, the existence check fires at start() time, not at registration time.","commonSituations":"Referencing a generated file (cert, key material) whose producing task was not declared as an input dependency of the test cluster. Typo in the path. File created in a different subproject's build dir. Resource path resolved against the wrong project. CI checked out without large files / git-lfs objects.","solutions":["Verify the path printed in the message exists on disk at the time the test cluster starts: ls -la <path>.","If the file is generated by another task, wire it through a Provider/FileCollection so Gradle creates the task dependency, e.g. keystoreFile('my.setting', generateKeyTask.flatMap { it.outputFile }).","If it is a checked-in resource, confirm it is committed and (for git-lfs) pulled on the CI agent.","Use an absolute path or resolve via project.layout.projectDirectory.file(...) to avoid working-directory ambiguity."],"exampleFix":"// before: static file path that may not exist\nkeystoreFile('bootstrap.password', new File('certs/key.txt'))\n// after: wire a task output as a provider so it exists before start\nkeystoreFile('bootstrap.password', generateKeyTask.flatMap { it.outputFile.asFile })","handlingStrategy":"validation","validationCode":"// Validate keystore files exist before starting\nnode.getKeystoreFiles().forEach((k, f) -> {\n    requireNonNull(f, \"keystoreFile null for key \" + k);\n    if (!f.exists()) {\n        throw new IllegalStateException(\"keystoreFile missing for key \" + k + \": \" + f);\n    }\n});\n// Prefer wiring task outputs as providers so Gradle builds them before start().","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Wire generated keystore material through Provider<File> task outputs, not static Files.","Commit checked-in key material (or pull git-lfs on CI).","Resolve paths via project.layout.projectDirectory.file(...) to avoid working-dir ambiguity."],"tags":["testclusters","keystore","filesystem","validation","security"],"backgroundTag":null,"analyzedSha":"db6a809a667c081ca1dc7500389d26975573215f","analyzedAt":"2026-08-12T01:39:14.192Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}