elastic/elasticsearch · error · IllegalStateException
Unknown license for license file: {}
Error message
Unknown license for license file: {} What it means
Thrown by LicenseAnalyzer.licenseType(File) when no LicenseMatcher pattern in the hardcoded matchers array matches the given license file's content. The analyzer recognises a fixed set (Apache-2.0, BSD-2/3-Clause, CDDL-1.0/1.1, ICU, MIT, MIT-0, MPL-1.1/2.0, XZ, EPL-2.0, EDL-1.0, LGPL-2.1/3.0, GeoLite, GeoIp-Database-Service). Any dependency whose LICENSE file does not match one of these patterns is rejected so an untracked license cannot slip into the distribution.
Source
Thrown at build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/precommit/LicenseAnalyzer.java:155
"GeoIp-Database-Service",
false,
false,
Pattern.compile(
("By using the GeoIP Database Service, you agree to the Elastic GeoIP Database Service Agreement,\n"
+ "available at www.elastic.co/elastic-geoip-database-service-terms.").replaceAll("\\s+", "\\\\s*"),
Pattern.DOTALL
)
) };
public static LicenseInfo licenseType(File licenseFile) {
for (LicenseMatcher matcher : matchers) {
boolean matches = matcher.matches(licenseFile);
if (matches) {
return new LicenseInfo(matcher.identifier(), matcher.spdxLicense, matcher.sourceRedistributionRequired);
}
}
throw new IllegalStateException("Unknown license for license file: " + licenseFile);
}
public record LicenseInfo(String identifier, boolean spdxLicense, boolean sourceRedistributionRequired) {}
private record LicenseMatcher(String identifier, boolean spdxLicense, boolean sourceRedistributionRequired, Pattern pattern) {
public boolean matches(File licenseFile) {
try {
String content = Files.readString(licenseFile.toPath()).replaceAll("\\*", " ");
return pattern.matcher(content).find();
} catch (IOException e) {
throw new UncheckedIOException(e);
}
}
}
}
View on GitHub (pinned to db6a809a66)
Solutions
- Open the offending LICENSE file and compare its text against the closest matcher pattern in LicenseAnalyzer.
- If the license is acceptable and missing, add a new LicenseMatcher entry with a regex that matches this file's boilerplate.
- If the license is not acceptable for the distribution, remove the dependency.
- Re-run dependencyLicenses to confirm the file now resolves.
Example fix
// before: new dep with ISC license -> IllegalStateException
// after: add a matcher
new LicenseMatcher("ISC", true, false,
Pattern.compile("Permission to use, copy, modify, and.*ISC License.*", Pattern.DOTALL)) Defensive patterns
Strategy: try-catch
Validate before calling
// Pre-check: try matching before throwing, and report which license file is unmatched
for (File lf : licenseFiles) {
boolean matched = Arrays.stream(LicenseAnalyzer.matchers).anyMatch(m -> m.matches(lf));
if (!matched) System.err.println("Unmatched LICENSE: " + lf);
} Try / catch
try {
LicenseAnalyzer.licenseType(licenseFile);
} catch (IllegalStateException e) {
// add a new LicenseMatcher regex or remove the dependency, then re-run dependencyLicenses
throw e;
} Prevention
- When adding a dependency, add its LICENSE file to the licenses dir and confirm dependencyLicenses resolves it.
- Keep LicenseMatcher patterns permissive enough to handle minor boilerplate reformatting.
- Review any dependency whose license is dual/recursive — pick the most permissive matching one explicitly.
When it happens
Trigger: A dependency's LICENSE file whose text does not match any of the compiled regex patterns — either it is a genuinely new license, a dual-license variant the patterns miss, or a heavily reformatted boilerplate.
Common situations: Adding a new third-party dependency with an unusual license; a license file with reformatted boilerplate (line wrapping, case changes) that breaks the regex; a license not yet in the allowed set (e.g. ISC, Unlicense, BSL); a dependency whose LICENSE file is actually a NOTICE or a custom EULA.
Related errors
- Unsupported classpath element: {}
- Cannot read ${f} to check for duplicate license headers
- Cannot generate license header report for ${path}
- Error parsing xml report ${xmlReportFileAbsolutePath}
- Failed to patch archive
AI-assisted analysis of elastic/elasticsearch@db6a809a66 (2026-08-12).
Data as JSON: /api/errors/54e60cb9233a9540.
Report an issue: GitHub.