{"record":{"id":"0d69d57f7996746b","repo":"jeecgboot/JeecgBoot","slug":"zip","errorCode":null,"errorMessage":"请上传zip压缩包","messagePattern":"请上传zip压缩包","errorType":"validation","errorClass":"JeecgBootException","httpStatus":null,"severity":"error","filePath":"jeecg-boot/jeecg-boot-module/jeecg-boot-module-airag/src/main/java/org/jeecg/modules/airag/llm/service/impl/AiragKnowledgeDocServiceImpl.java","lineNumber":308,"sourceCode":"    @Transactional(rollbackFor = {java.lang.Exception.class})\n    @Override\n    public Result<?> importDocumentFromZip(String knowId, MultipartFile zipFile) {\n        AssertUtils.assertNotEmpty(\"请先选择知识库\", knowId);\n        AssertUtils.assertNotEmpty(\"请上传文件\", zipFile);\n        long startTime = System.currentTimeMillis();\n        log.info(\"开始上传知识库文档(zip), 知识库id: {}, 文件名: {}\", knowId, zipFile.getOriginalFilename());\n\n        try {\n            String bizPath = knowId + File.separator + UUIDGenerator.generate();\n            String workDir = uploadpath + File.separator + bizPath + File.separator;\n            String sourcesPath = workDir + \"files\";\n\n            SsrfFileTypeFilter.checkUploadFileType(zipFile);\n            // 通过filePath 检查文件是不是压缩包(zip)\n            String zipFileName = FilenameUtils.getBaseName(zipFile.getOriginalFilename());\n            String fileExt = FilenameUtils.getExtension(zipFile.getOriginalFilename());\n            if (null == fileExt || !fileExt.equalsIgnoreCase(\"zip\")) {\n                throw new JeecgBootException(\"请上传zip压缩包\");\n            }\n            String uploadedZipPath = CommonUtils.uploadLocal(zipFile, bizPath, uploadpath);\n\n            //update-begin---wangshuai---date:20260414  for：【QQYUN-14932】创建知识库时，可以创建一个分段策略，知识库里面的文档默认使用知识库的分段策略------------\n            // 判断知识库是否配置了默认分段策略\n            boolean knowledgeHasDefaultSegment = false;\n            AiragKnowledge knowledge = airagKnowledgeMapper.selectById(knowId);\n            if (knowledge != null && oConvertUtils.isNotEmpty(knowledge.getMetadata())) {\n                try {\n                    JSONObject kmeta = JSONObject.parseObject(knowledge.getMetadata());\n                    knowledgeHasDefaultSegment = Boolean.TRUE.equals(kmeta.getBoolean(LLMConsts.ENABLE_SEGMENT));\n                } catch (Exception ignore) {}\n            }\n            final boolean useKnowledgeDefault = knowledgeHasDefaultSegment;\n            //update-end---author:wangshuai ---date:20260414  for：【QQYUN-14932】创建知识库时，可以创建一个分段策略，知识库里面的文档默认使用知识库的分段策略------------\n            \n            // 解压缩文件\n            List<AiragKnowledgeDoc> docList = new ArrayList<>();","sourceCodeStart":290,"sourceCodeEnd":326,"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/service/impl/AiragKnowledgeDocServiceImpl.java#L290-L326","documentation":"Thrown by AiragKnowledgeDocServiceImpl.importDocumentFromZip() when the uploaded file's extension is not 'zip' (case-insensitive). The method extracts the extension via FilenameUtils.getExtension() and rejects anything that is null or not equal to 'zip'. This is a file-type guard before the upload and extraction pipeline.","triggerScenarios":"Uploading a file with extension .rar, .7z, .tar, .gz, .tar.gz, or a file with no extension to the zip-import endpoint. Also triggered if the original filename has no dot (resulting in null extension).","commonSituations":"User selects a .rar or .7z file instead of .zip; the file was renamed but the content does not match; the browser or OS stripped the extension; user uploads a regular document file (e.g. .pdf) to the zip-import endpoint by mistake.","solutions":["Re-package the files as a .zip archive using the OS's built-in compression or a tool like 7-Zip.","Verify the uploaded file actually has a .zip extension and is a valid zip archive.","If individual files need to be uploaded (not in a zip), use the single-file upload endpoint instead."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"String fileExt = FilenameUtils.getExtension(zipFile.getOriginalFilename());\nif (fileExt == null || !fileExt.equalsIgnoreCase(\"zip\")) {\n    throw new JeecgBootException(\"请上传zip格式的压缩包\");\n}","typeGuard":"private static boolean isZipFile(MultipartFile file) {\n    if (file == null || file.getOriginalFilename() == null) return false;\n    String ext = FilenameUtils.getExtension(file.getOriginalFilename());\n    return \"zip\".equalsIgnoreCase(ext);\n}","tryCatchPattern":null,"preventionTips":["Verify the file has a .zip extension before uploading to the zip-import endpoint.","Use the OS built-in compression or 7-Zip to create zip archives.","Add frontend file-type filtering to restrict uploads to .zip files."],"tags":["validation","file-upload","zip","rag"],"backgroundTag":null,"analyzedSha":"96fb33f5ec68516da0b0147da06b2eb0419e063a","analyzedAt":"2026-08-14T00:04:16.786Z","schemaVersion":2},"datasetVersion":"2026-08-14T00:17:13.853Z"}