jeecgboot/JeecgBoot · warning · IllegalArgumentException
不支持的文件格式:
Error message
不支持的文件格式:
What it means
This error is thrown by TikaDocumentParser when the uploaded file's extension is not in the supported formats list. The parser supports: .txt, .md, .pdf (via Tika), and .docx, .doc, .pptx, .ppt, .xlsx, .xls (via Apache POI). Any other extension triggers this rejection. The FILE_SUFFIX set at line 58 defines the POI-supported extensions.
Source
Thrown at jeecg-boot/jeecg-boot-module/jeecg-boot-module-airag/src/main/java/org/jeecg/modules/airag/llm/document/TikaDocumentParser.java:92
// 使用 Tika 自动检测 MIME 类型
String fileName = file.getName().toLowerCase();
//后缀
String ext = FilenameUtils.getExtension(fileName);
if (fileName.endsWith(".txt")
|| fileName.endsWith(".md")
|| fileName.endsWith(".pdf")) {
// 用于解析(使用FileInputStream避免file.toPath()在Linux非UTF-8环境下中文文件名报错)
try (InputStream isForParsing = new FileInputStream(file)) {
return extractByTika(isForParsing);
} catch (IOException e) {
throw new RuntimeException(e);
}
//update-begin---author:wangshuai---date:2026-01-09---for:【QQYUN-14261】【AI】AI助手,支持多模态能力- 文档---
} else if (FILE_SUFFIX.contains(ext.toLowerCase())) {
return parseDocExcelPdfUsingApachePoi(file);
//update-end---author:wangshuai---date:2026-01-09---for:【QQYUN-14261】【AI】AI助手,支持多模态能力- 文档---
} else {
throw new IllegalArgumentException("不支持的文件格式: " + FilenameUtils.getExtension(fileName));
}
}
/**
* langchain4j 内部解析器
* @param file
* @return
*/
public Document parseDocExcelPdfUsingApachePoi(File file) {
AssertUtils.assertNotEmpty("请选择文件", file);
try (InputStream inputStream = new FileInputStream(file)) {
ApachePoiDocumentParser parser = new ApachePoiDocumentParser();
Document document = parser.parse(inputStream);
if (document == null || Utils.isNullOrBlank(document.text())) {
return null;
}
return document;
} catch (BlankDocumentException e) {View on GitHub (pinned to 96fb33f5ec)
Solutions
- Convert the file to one of the supported formats before uploading: .txt, .md, .pdf, .docx, .doc, .pptx, .ppt, .xlsx, or .xls.
- If you need to support additional formats, extend the FILE_SUFFIX set and implement the corresponding parser in TikaDocumentParser.
- For CSV/HTML content, paste the text directly into a .txt or .md document.
- Check the actual file extension (not just the content type) — the parser uses FilenameUtils.getExtension on the file name.
Example fix
// Not applicable (runtime guard). User action required: // before — upload .csv file → rejected // after — convert to .xlsx or paste content into .txt, then upload
Defensive patterns
Strategy: validation
Validate before calling
// Validate file extension before attempting to parse
private static final Set<String> SUPPORTED = Set.of("txt","md","pdf","docx","doc","pptx","ppt","xlsx","xls");
public static boolean isSupportedFormat(String fileName) {
String ext = FilenameUtils.getExtension(fileName).toLowerCase();
return SUPPORTED.contains(ext);
}
// Use before upload
if (!isSupportedFormat(fileName)) {
throw new IllegalArgumentException("Unsupported format. Supported: " + SUPPORTED);
} Type guard
public static boolean isParsableFormat(File file) {
if (file == null) return false;
String name = file.getName().toLowerCase();
if (name.endsWith(".txt") || name.endsWith(".md") || name.endsWith(".pdf")) return true;
String ext = FilenameUtils.getExtension(name);
return Set.of("docx","doc","pptx","ppt","xlsx","xls").contains(ext);
} Try / catch
try {
Document doc = tikaDocumentParser.parse(file);
return doc;
} catch (IllegalArgumentException e) {
if (e.getMessage().startsWith("不支持的文件格式")) {
// Convert to user-friendly message
throw new BusinessException("文件格式不支持,请使用 TXT/MD/PDF/DOC/DOCX/XLS/XLSX/PPT/PPTX 格式");
}
throw e;
} Prevention
- Implement client-side file extension validation before upload
- Display supported formats in the upload UI
- Use a whitelist of allowed extensions rather than a blacklist
- Consider converting unsupported formats server-side before parsing
When it happens
Trigger: A file is uploaded to the AI knowledge base document parsing pipeline with an extension that is not in the supported set. For example: .rtf, .odt, .csv, .json, .html, .epub, .pages, or any other non-standard format. The parser first checks for .txt/.md/.pdf, then checks FILE_SUFFIX for Office formats, and falls through to the else block for everything else.
Common situations: User uploads an RTF or ODF file thinking it's supported. File was renamed with a wrong extension. A format the user expects to work (like .csv or .html) is not in the supported list by design.
Related errors
AI-assisted analysis of jeecgboot/JeecgBoot@96fb33f5ec (2026-08-14).
Data as JSON: /api/errors/4478b87a7565f251.
Report an issue: GitHub.