{"record":{"id":"4478b87a7565f251","repo":"jeecgboot/JeecgBoot","slug":"error-4478b8","errorCode":null,"errorMessage":"不支持的文件格式: ","messagePattern":"不支持的文件格式: ","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"warning","filePath":"jeecg-boot/jeecg-boot-module/jeecg-boot-module-airag/src/main/java/org/jeecg/modules/airag/llm/document/TikaDocumentParser.java","lineNumber":92,"sourceCode":"        // 使用 Tika 自动检测 MIME 类型\n        String fileName = file.getName().toLowerCase();\n        //后缀\n        String ext = FilenameUtils.getExtension(fileName);\n        if (fileName.endsWith(\".txt\")\n                || fileName.endsWith(\".md\")\n                || fileName.endsWith(\".pdf\")) {\n            // 用于解析(使用FileInputStream避免file.toPath()在Linux非UTF-8环境下中文文件名报错)\n            try (InputStream isForParsing = new FileInputStream(file)) {\n                return extractByTika(isForParsing);\n            } catch (IOException e) {\n                throw new RuntimeException(e);\n            }\n        //update-begin---author:wangshuai---date:2026-01-09---for:【QQYUN-14261】【AI】AI助手，支持多模态能力- 文档---\n        } else if (FILE_SUFFIX.contains(ext.toLowerCase())) {\n            return parseDocExcelPdfUsingApachePoi(file);\n        //update-end---author:wangshuai---date:2026-01-09---for:【QQYUN-14261】【AI】AI助手，支持多模态能力- 文档---\n        } else {\n            throw new IllegalArgumentException(\"不支持的文件格式: \" + FilenameUtils.getExtension(fileName));\n        }\n    }\n\n    /**\n     * langchain4j 内部解析器\n     * @param file\n     * @return\n     */\n    public Document parseDocExcelPdfUsingApachePoi(File file) {\n        AssertUtils.assertNotEmpty(\"请选择文件\", file);\n        try (InputStream inputStream = new FileInputStream(file)) {\n            ApachePoiDocumentParser parser = new ApachePoiDocumentParser();\n            Document document = parser.parse(inputStream);\n            if (document == null || Utils.isNullOrBlank(document.text())) {\n                return null;\n            }\n            return document;\n        } catch (BlankDocumentException e) {","sourceCodeStart":74,"sourceCodeEnd":110,"githubUrl":"https://github.com/jeecgboot/JeecgBoot/blob/96fb33f5ec68516da0b0147da06b2eb0419e063a/jeecg-boot/jeecg-boot-module/jeecg-boot-module-airag/src/main/java/org/jeecg/modules/airag/llm/document/TikaDocumentParser.java#L74-L110","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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."],"exampleFix":"// Not applicable (runtime guard). User action required:\n// before — upload .csv file → rejected\n// after — convert to .xlsx or paste content into .txt, then upload","handlingStrategy":"validation","validationCode":"// Validate file extension before attempting to parse\nprivate static final Set<String> SUPPORTED = Set.of(\"txt\",\"md\",\"pdf\",\"docx\",\"doc\",\"pptx\",\"ppt\",\"xlsx\",\"xls\");\npublic static boolean isSupportedFormat(String fileName) {\n    String ext = FilenameUtils.getExtension(fileName).toLowerCase();\n    return SUPPORTED.contains(ext);\n}\n// Use before upload\nif (!isSupportedFormat(fileName)) {\n    throw new IllegalArgumentException(\"Unsupported format. Supported: \" + SUPPORTED);\n}","typeGuard":"public static boolean isParsableFormat(File file) {\n    if (file == null) return false;\n    String name = file.getName().toLowerCase();\n    if (name.endsWith(\".txt\") || name.endsWith(\".md\") || name.endsWith(\".pdf\")) return true;\n    String ext = FilenameUtils.getExtension(name);\n    return Set.of(\"docx\",\"doc\",\"pptx\",\"ppt\",\"xlsx\",\"xls\").contains(ext);\n}","tryCatchPattern":"try {\n    Document doc = tikaDocumentParser.parse(file);\n    return doc;\n} catch (IllegalArgumentException e) {\n    if (e.getMessage().startsWith(\"不支持的文件格式\")) {\n        // Convert to user-friendly message\n        throw new BusinessException(\"文件格式不支持，请使用 TXT/MD/PDF/DOC/DOCX/XLS/XLSX/PPT/PPTX 格式\");\n    }\n    throw e;\n}","preventionTips":["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"],"tags":["airag","file-format","document-parsing","validation"],"backgroundTag":null,"analyzedSha":"96fb33f5ec68516da0b0147da06b2eb0419e063a","analyzedAt":"2026-08-14T00:04:16.786Z","schemaVersion":2},"datasetVersion":"2026-08-14T00:17:13.853Z"}