{"record":{"id":"9950e30901d13d29","repo":"languagetool-org/languagetool","slug":"unknown-file-name-expected-xml-or-bz2-xm-9950e3","errorCode":null,"errorMessage":"Unknown file name, expected '.xml' or '.bz2': + xmlDumpPath","messagePattern":"Unknown file name, expected '\\.xml' or '\\.bz2': \\+ xmlDumpPath","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"languagetool-wikipedia/src/main/java/org/languagetool/dev/dumpcheck/WikipediaSpecificCaseExpressionExtractor.java","lineNumber":76,"sourceCode":"   * given file. Based on the extract method of the WikipediaSentenceExtractor.\n   * \n   * @param language    the language of the xml dump\n   * @param xmlDumpPath the path of the xml dump\n   * @param outputFile  the path of the file to write the extracted expressions\n   */\n  private void extractSpecificCaseExpressions(Language language, \n               String xmlDumpPath, String outputFile) \n               throws IOException, CompressorException {\n    try (FileInputStream fis = new FileInputStream(xmlDumpPath);\n    BufferedInputStream bis = new BufferedInputStream(fis);\n    FileWriter fw = new FileWriter(outputFile)) {\n      InputStream input;\n      if (xmlDumpPath.endsWith(\".bz2\")) {\n        input = new CompressorStreamFactory().createCompressorInputStream(bis);\n      } else if (xmlDumpPath.endsWith(\".xml\")) {\n        input = bis;\n      } else {\n        throw new IllegalArgumentException(\"Unknown file name, expected '.xml' or '.bz2': \" \n                                              + xmlDumpPath);\n      }\n      WikipediaSentenceSource source = new WikipediaSentenceSource(input, language);\n      while (source.hasNext()) {\n        String sentence = source.next().getText();\n        if (skipSentence(sentence)) {\n          continue;\n        }\n        detectSpecificCaseExpressions(sentence);\n      }\n  \n      specificCaseExpressionsCounter = sortByValue(specificCaseExpressionsCounter);\n      int number_of_expressions_added = 0;\n      for (String foundExpression : specificCaseExpressionsCounter.keySet()) {\n        // System.out.println(foundExpression + \" : \" +\n         // specificCaseExpressionsCounter.get(foundExpression));\n        fw.write(foundExpression);\n        fw.write('\\n');","sourceCodeStart":58,"sourceCodeEnd":94,"githubUrl":"https://github.com/languagetool-org/languagetool/blob/2e990059ce67d5e2a0f7f7ca5d31160c6709df4b/languagetool-wikipedia/src/main/java/org/languagetool/dev/dumpcheck/WikipediaSpecificCaseExpressionExtractor.java#L58-L94","documentation":"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.","triggerScenarios":"Calling extractSpecificCaseExpressions (directly or via main) with a dump path whose name ends in neither .xml nor .bz2.","commonSituations":"Same as error 408: .gz/.zip dumps, extension-stripped downloads, renamed files.","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"],"exampleFix":"// before\nextractor.extractSpecificCaseExpressions(\"dump.xml.zip\", lang, out);\n// after\n// unzip first, then:\nextractor.extractSpecificCaseExpressions(\"dump.xml\", lang, out);","handlingStrategy":"validation","validationCode":"if (!xmlDumpPath.endsWith(\".xml\") && !xmlDumpPath.endsWith(\".bz2\")) {\n  throw new IllegalArgumentException(\"Expected .xml or .bz2 dump: \" + xmlDumpPath);\n}","typeGuard":null,"tryCatchPattern":"try {\n  extractor.extractSpecificCaseExpressions(xmlDumpPath, language, output);\n} catch (IllegalArgumentException e) {\n  if (e.getMessage() != null && e.getMessage().contains(\"Unknown file name\")) {\n    System.err.println(\"Rename/convert dump: \" + e.getMessage());\n  } else throw e;\n}","preventionTips":["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)"],"tags":["file-naming","unsupported-compression","cli"],"backgroundTag":"unsupported-file-extension","analyzedSha":"2e990059ce67d5e2a0f7f7ca5d31160c6709df4b","analyzedAt":"2026-09-06T09:20:17.015Z","contentChangedAt":"2026-09-06T09:20:17.015Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}