languagetool-org/languagetool · error · IllegalArgumentException
Unknown file name, expected '.xml' or '.bz2': + xmlDumpPath
Error message
Unknown file name, expected '.xml' or '.bz2': + xmlDumpPath
What it means
WikipediaSpecificCaseExpressionExtractor.extractSpecificCaseExpressions contains the same extension dispatch as WikipediaSentenceExtractor: .bz2 is decompressed, .xml read raw, and any other suffix throws an IllegalArgumentException. Note the message here is missing a '+' separator in its concatenation-free text ('.bz2: + xmlDumpPath'), a cosmetic bug, but the behavior is identical.
Source
Thrown at languagetool-wikipedia/src/main/java/org/languagetool/dev/dumpcheck/WikipediaSpecificCaseExpressionExtractor.java:76
* given file. Based on the extract method of the WikipediaSentenceExtractor.
*
* @param language the language of the xml dump
* @param xmlDumpPath the path of the xml dump
* @param outputFile the path of the file to write the extracted expressions
*/
private void extractSpecificCaseExpressions(Language language,
String xmlDumpPath, String outputFile)
throws IOException, CompressorException {
try (FileInputStream fis = new FileInputStream(xmlDumpPath);
BufferedInputStream bis = new BufferedInputStream(fis);
FileWriter fw = new FileWriter(outputFile)) {
InputStream input;
if (xmlDumpPath.endsWith(".bz2")) {
input = new CompressorStreamFactory().createCompressorInputStream(bis);
} else if (xmlDumpPath.endsWith(".xml")) {
input = bis;
} else {
throw new IllegalArgumentException("Unknown file name, expected '.xml' or '.bz2': "
+ xmlDumpPath);
}
WikipediaSentenceSource source = new WikipediaSentenceSource(input, language);
while (source.hasNext()) {
String sentence = source.next().getText();
if (skipSentence(sentence)) {
continue;
}
detectSpecificCaseExpressions(sentence);
}
specificCaseExpressionsCounter = sortByValue(specificCaseExpressionsCounter);
int number_of_expressions_added = 0;
for (String foundExpression : specificCaseExpressionsCounter.keySet()) {
// System.out.println(foundExpression + " : " +
// specificCaseExpressionsCounter.get(foundExpression));
fw.write(foundExpression);
fw.write('\n');View on GitHub (pinned to 2e990059ce)
Solutions
- Rename the file to end with .xml or .bz2
- Recompress/decompress to a supported format before running
- Confirm the path passed on the command line is correct
Example fix
// before
extractor.extractSpecificCaseExpressions("dump.xml.zip", lang, out);
// after
// unzip first, then:
extractor.extractSpecificCaseExpressions("dump.xml", lang, out); Defensive patterns
Strategy: validation
Validate before calling
if (!xmlDumpPath.endsWith(".xml") && !xmlDumpPath.endsWith(".bz2")) {
throw new IllegalArgumentException("Expected .xml or .bz2 dump: " + xmlDumpPath);
} Try / catch
try {
extractor.extractSpecificCaseExpressions(xmlDumpPath, language, output);
} catch (IllegalArgumentException e) {
if (e.getMessage() != null && e.getMessage().contains("Unknown file name")) {
System.err.println("Rename/convert dump: " + e.getMessage());
} else throw e;
} Prevention
- Same as WikipediaSentenceExtractor: only .xml/.bz2 supported
- Unzip/ungzip beforehand
- Validate extension in scripts
- Beware the misleading message text when grepping logs (missing '+' in concatenation)
When it happens
Trigger: Calling extractSpecificCaseExpressions (directly or via main) with a dump path whose name ends in neither .xml nor .bz2.
Common situations: Same as error 408: .gz/.zip dumps, extension-stripped downloads, renamed files.
Related errors
- Unknown file name, expected '.xml' or '.bz2': ${xmlDumpPath}
- WrongParameterNumberException
- Unknown level '<level>' - currently, only 'PICKY' is support
- You cannot list unknown words when tagging only
- You cannot apply suggestions when tagging only
AI-assisted analysis of languagetool-org/languagetool@2e990059ce (2026-09-06).
Data as JSON: /api/errors/9950e30901d13d29.
Report an issue: GitHub.