{"record":{"id":"4774bf3c4df164f5","repo":"elastic/elasticsearch","slug":"cannot-generate-license-header-report-for-path","errorCode":null,"errorMessage":"Cannot generate license header report for ${path}","messagePattern":"Cannot generate license header report for (.+?)","errorType":"exception","errorClass":"GradleException","httpStatus":null,"severity":"error","filePath":"build-conventions/src/main/java/org/elasticsearch/gradle/internal/conventions/precommit/LicenseHeadersTask.java","lineNumber":303,"sourceCode":"    }\n\n    private IHeaderMatcher subStringMatcher(String licenseFamilyCategory, String licenseFamilyName, String substringPattern) {\n        SubstringLicenseMatcher substringLicenseMatcher = new SubstringLicenseMatcher();\n        substringLicenseMatcher.setLicenseFamilyCategory(licenseFamilyCategory);\n        substringLicenseMatcher.setLicenseFamilyName(licenseFamilyName);\n        SubstringLicenseMatcher.Pattern pattern = new SubstringLicenseMatcher.Pattern();\n        pattern.setSubstring(substringPattern);\n        substringLicenseMatcher.addConfiguredPattern(pattern);\n        return substringLicenseMatcher;\n    }\n\n    private ClaimStatistic generateReport(ReportConfiguration config, File xmlReportFile) {\n        try {\n            Files.deleteIfExists(reportFile.get().getAsFile().toPath());\n            BufferedWriter bufferedWriter = new BufferedWriter(new FileWriter(xmlReportFile));\n            return toXmlReportFile(config, bufferedWriter);\n        } catch (IOException | RatException exception) {\n            throw new GradleException(\"Cannot generate license header report for \" + getPath(), exception);\n        }\n    }\n\n    private ClaimStatistic toXmlReportFile(ReportConfiguration config, Writer writer) throws RatException, IOException {\n        ClaimStatistic stats = new ClaimStatistic();\n        RatReport standardReport = XmlReportFactory.createStandardReport(new XmlWriter(writer), stats, config);\n\n        standardReport.startReport();\n        for (FileCollection dirSet : getSourceFolders().get()) {\n            for (File f : dirSet.getAsFileTree().matching(patternFilterable -> patternFilterable.exclude(getExcludes()))) {\n                standardReport.report(new FileDocument(f));\n            }\n        }\n        standardReport.endReport();\n        writer.flush();\n        writer.close();\n        return stats;\n    }","sourceCodeStart":285,"sourceCodeEnd":321,"githubUrl":"https://github.com/elastic/elasticsearch/blob/db6a809a667c081ca1dc7500389d26975573215f/build-conventions/src/main/java/org/elasticsearch/gradle/internal/conventions/precommit/LicenseHeadersTask.java#L285-L321","documentation":"generateReport deletes the previous report file, opens an XML writer, and delegates to RAT's toXmlReportFile which scans every source file. Any IOException or RatException from that pipeline — writer failure, RAT analysis error, inability to create the report file — is wrapped as this GradleException prefixed with the task's path.","triggerScenarios":"The report output directory does not exist or is not writable; a RAT document analysis throws RatException on a malformed input; a disk/encoding IOException while writing the XML; the reportFile path is on a read-only filesystem.","commonSituations":"Building on a read-only filesystem or container volume; an older RAT version incompatible with the inputs; a path collision where reportFile is also a source input; permissions on the build/ directory.","solutions":["Ensure build/reports/licenseHeaders/ is writable and its parent exists.","Inspect the caused-by exception — RatException vs IOException points to different causes.","Verify the RAT dependency version matches what build-conventions expects.","Clean the build directory: `./gradlew clean` and rerun."],"exampleFix":"// before: report dir on read-only volume\n// after: point gradle build dir at a writable location\n./gradlew licenseHeaders -Dorg.gradle.buildDir=/tmp/es-build","handlingStrategy":"try-catch","validationCode":"File reportDir = reportFile.getAsFile().get().getParentFile();\nif (!reportDir.exists() && !reportDir.mkdirs()) {\n    throw new GradleException(\"Cannot create license report dir: \" + reportDir);\n}","typeGuard":null,"tryCatchPattern":"try {\n    ClaimStatistic stats = generateReport(config, reportXml);\n} catch (GradleException e) {\n    if (e.getMessage().startsWith(\"Cannot generate license header report\")) {\n        // inspect e.getCause(): IOException -> fs/disk; RatException -> input\n        throw new GradleException(\"License report generation failed: \" + e.getCause(), e.getCause());\n    }\n    throw e;\n}","preventionTips":["Ensure build/reports is on a writable filesystem.","Pin the RAT version expected by build-conventions.","Clean the build dir before re-running after a disk-full event."],"tags":["gradle","license","io","precommit","report"],"backgroundTag":null,"analyzedSha":"db6a809a667c081ca1dc7500389d26975573215f","analyzedAt":"2026-08-12T01:39:14.192Z","schemaVersion":2},"datasetVersion":"2026-08-12T12:31:55.035Z"}