{"record":{"id":"9d6fcc09e2df132a","repo":"elastic/elasticsearch","slug":"failed-to-write-keywords-report","errorCode":null,"errorMessage":"Failed to write keywords report","messagePattern":"Failed to write keywords report","errorType":"exception","errorClass":"GradleException","httpStatus":null,"severity":"error","filePath":"build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/precommit/ValidateJsonNoKeywordsTask.java","lineNumber":193,"sourceCode":"                pw.println(\"---------- Validation Report -----------\");\n                pw.println(\"Some API names were found that, when client code is generated for these APIS,\");\n                pw.println(\"could conflict with the reserved words in some programming languages. It may\");\n                pw.println(\"still be possible to use these API names, but you will need to verify whether\");\n                pw.println(\"the API name (and its components) can be used as method names, and update the\");\n                pw.println(\"list of keywords below. The safest action is to rename the API to avoid conflicts.\");\n                pw.println();\n                pw.printf(\"Keywords source: %s%n\", getJsonKeywords());\n                pw.println();\n                pw.println(\"---------- Validation Errors -----------\");\n                pw.println();\n                errors.forEach((file, errorsForFile) -> {\n                    pw.printf(\"File: %s%n\", file);\n                    errorsForFile.forEach(err -> pw.printf(\"\\t%s%n\", err));\n                    pw.println();\n                });\n            }\n        } catch (FileNotFoundException e) {\n            throw new GradleException(\"Failed to write keywords report\", e);\n        }\n\n        String message = String.format(\n            Locale.ROOT,\n            \"Error validating JSON. See the report at: %s%s%s\",\n            getReport().toURI().toASCIIString(),\n            System.lineSeparator(),\n            String.format(\"Verification failed: %d files contained %d violations\", errors.keySet().size(), errors.values().size())\n        );\n        throw problemReporter.throwing(new GradleException(message), problems);\n    }\n\n    /**\n     * Loads the known keywords. Although the JSON on disk maps from language to keywords, this method\n     * inverts this to map from keyword to languages. This is because the same keywords are found in\n     * multiple languages, so it is easier and more useful to have a single map of keywords.\n     *\n     * @return a mapping from keyword to languages.","sourceCodeStart":175,"sourceCodeEnd":211,"githubUrl":"https://github.com/elastic/elasticsearch/blob/db6a809a667c081ca1dc7500389d26975573215f/build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/precommit/ValidateJsonNoKeywordsTask.java#L175-L211","documentation":"Thrown by ValidateJsonNoKeywordsTask when writing the validation error report file raises a FileNotFoundException. The report writer (PrintWriter over the report path) fails if the report file's parent directory does not exist or cannot be created/opened, so the task cannot persist the detailed per-file violation listing and aborts.","triggerScenarios":"The task detected JSON keyword violations and attempts to write a human-readable report to getReport(); if the destination path's parent directory is missing, read-only, or the path points to a directory, the FileOutputStream throws FileNotFoundException which is caught and rethrown as this GradleException.","commonSituations":"The configured report directory was never created (task assumes a parent exists); build output dir cleaned/deleted between detection and report write; filesystem permission issue in the build dir; a misconfigured reports.outputLocation or custom report path pointing into a non-existent folder.","solutions":["Ensure the report's parent directory is created before the task writes — typically Gradle creates build/ dirs, so run a clean build; if a custom report path is set, verify its parent exists.","Check filesystem permissions on the build output directory and that it is not read-only.","If the report path was overridden in configuration, point it at a writable, existing directory.","Re-run the task after fixing; the underlying JSON keyword violations still need resolving but the report will then write successfully."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"Path report = getReport();\nFiles.createDirectories(report.getParent());\nif (Files.isWritable(report.getParent()) == false) {\n    throw new IllegalStateException(\"Report dir not writable: \" + report.getParent());\n}","typeGuard":null,"tryCatchPattern":"try { writeReport(reportPath, errors); }\ncatch (GradleException e) {\n    if (e.getCause() instanceof FileNotFoundException) { /* ensure parent dir, retry once */ }\n    throw e;\n}","preventionTips":["Let Gradle manage report output under build/ rather than overriding to custom paths.","Run a clean build so build/ dirs are recreated.","Verify filesystem permissions on custom report directories."],"tags":["build","gradle","precommit","json","io","report"],"backgroundTag":null,"analyzedSha":"db6a809a667c081ca1dc7500389d26975573215f","analyzedAt":"2026-08-12T01:39:14.192Z","schemaVersion":2},"datasetVersion":"2026-08-12T12:31:55.035Z"}