elastic/elasticsearch · error · GradleException
Failed to write keywords report
Error message
Failed to write keywords report
What it means
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.
Source
Thrown at build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/precommit/ValidateJsonNoKeywordsTask.java:193
pw.println("---------- Validation Report -----------");
pw.println("Some API names were found that, when client code is generated for these APIS,");
pw.println("could conflict with the reserved words in some programming languages. It may");
pw.println("still be possible to use these API names, but you will need to verify whether");
pw.println("the API name (and its components) can be used as method names, and update the");
pw.println("list of keywords below. The safest action is to rename the API to avoid conflicts.");
pw.println();
pw.printf("Keywords source: %s%n", getJsonKeywords());
pw.println();
pw.println("---------- Validation Errors -----------");
pw.println();
errors.forEach((file, errorsForFile) -> {
pw.printf("File: %s%n", file);
errorsForFile.forEach(err -> pw.printf("\t%s%n", err));
pw.println();
});
}
} catch (FileNotFoundException e) {
throw new GradleException("Failed to write keywords report", e);
}
String message = String.format(
Locale.ROOT,
"Error validating JSON. See the report at: %s%s%s",
getReport().toURI().toASCIIString(),
System.lineSeparator(),
String.format("Verification failed: %d files contained %d violations", errors.keySet().size(), errors.values().size())
);
throw problemReporter.throwing(new GradleException(message), problems);
}
/**
* Loads the known keywords. Although the JSON on disk maps from language to keywords, this method
* inverts this to map from keyword to languages. This is because the same keywords are found in
* multiple languages, so it is easier and more useful to have a single map of keywords.
*
* @return a mapping from keyword to languages.View on GitHub (pinned to db6a809a66)
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.
Defensive patterns
Strategy: validation
Validate before calling
Path report = getReport();
Files.createDirectories(report.getParent());
if (Files.isWritable(report.getParent()) == false) {
throw new IllegalStateException("Report dir not writable: " + report.getParent());
} Try / catch
try { writeReport(reportPath, errors); }
catch (GradleException e) {
if (e.getCause() instanceof FileNotFoundException) { /* ensure parent dir, retry once */ }
throw e;
} Prevention
- 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.
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- Cannot generate license header report for ${path}
- Failed to load keywords JSON from {jsonKeywords} - {message}
- Cannot read ${f} to check for duplicate license headers
- Error parsing xml report ${xmlReportFileAbsolutePath}
- IO problem while reading files with API signatures.
AI-assisted analysis of elastic/elasticsearch@db6a809a66 (2026-08-12).
Data as JSON: /api/errors/9d6fcc09e2df132a.
Report an issue: GitHub.