{"record":{"id":"0aec0e95cae7d7c5","repo":"alibaba/spring-ai-alibaba","slug":"unsupported-format","errorCode":null,"errorMessage":"unsupported format: ","messagePattern":"unsupported format: ","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"spring-ai-alibaba-admin/spring-ai-alibaba-admin-server-core/src/main/java/com/alibaba/cloud/ai/studio/core/rag/indices/KnowledgeBaseIndexPipeline.java","lineNumber":122,"sourceCode":"\t\t\t}\n\t\t\tcase \"doc\", \"docx\", \"ppt\", \"pptx\": {\n\t\t\t\tDocumentReader reader = new TikaDocumentReader(new FileSystemResource(file));\n\t\t\t\tdocuments = reader.get();\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase \"md\", \"markdown\": {\n\t\t\t\tDocumentReader reader = new MarkdownDocumentReader(new FileSystemResource(file),\n\t\t\t\t\t\tMarkdownDocumentReaderConfig.defaultConfig());\n\t\t\t\tdocuments = reader.get();\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase \"txt\": {\n\t\t\t\tDocumentReader reader = new TextDocumentReader(new FileSystemResource(file));\n\t\t\t\tdocuments = reader.get();\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tdefault:\n\t\t\t\tthrow new IllegalArgumentException(\"unsupported format: \" + format);\n\t\t}\n\n\t\tlog.info(\"{} documents parsed\", documents.size());\n\n\t\treturn documents;\n\t}\n\n\t/**\n\t * Transforms documents by splitting them into chunks\n\t * @param documents Documents to transform\n\t * @param processConfig Configuration for the transformation process\n\t * @return List of transformed documents\n\t */\n\tpublic List<Document> transform(List<Document> documents, ProcessConfig processConfig) {\n\n\t\t// TODO now use this simple chunk splitter first\n\t\tChunkType chunkType = processConfig.getChunkType();\n\t\tTextSplitter splitter = null;","sourceCodeStart":104,"sourceCodeEnd":140,"githubUrl":"https://github.com/alibaba/spring-ai-alibaba/blob/f82da0b50f35744c13968191be2b1cd2452ef550/spring-ai-alibaba-admin/spring-ai-alibaba-admin-server-core/src/main/java/com/alibaba/cloud/ai/studio/core/rag/indices/KnowledgeBaseIndexPipeline.java#L104-L140","documentation":"KnowledgeBaseIndexPipeline.parse switches on the lowercased document format (pdf, docx, txt, etc.) to pick a DocumentReader; an unrecognized format falls to default and throws IllegalArgumentException \"unsupported format: \" + format. Only the formats mapped to readers in the switch can be parsed.","triggerScenarios":"Indexing a document whose file extension/format string is not one of the supported cases (e.g. .md, .csv, .xlsx, .html), or an empty/unset format value that lowercases to something unmatched.","commonSituations":"Users uploading Markdown or CSV files to the knowledge base through the UI; format derived from extension of a file with wrong/double extension (report.pdf.txt); format metadata missing so the switch gets null.","solutions":["Convert the document to a supported format (pdf, docx, or txt) before uploading.","Verify the document's format field is set correctly and matches the actual file.","Add a new case with an appropriate DocumentReader if you need to support additional formats."],"exampleFix":"// before\ndefault:\n    throw new IllegalArgumentException(\"unsupported format: \" + format);\n// after\ncase \"md\": {\n    DocumentReader reader = new TextDocumentReader(new FileSystemResource(file));\n    documents = reader.get();\n    break;\n}\ndefault:\n    throw new IllegalArgumentException(\"unsupported format: \" + format);","handlingStrategy":"validation","validationCode":"// Java\nSet<String> supported = Set.of(\"pdf\", \"docx\", \"txt\");\nif (format == null || !supported.contains(format.toLowerCase())) {\n    throw new IllegalArgumentException(\"Format \" + format + \" is not supported; convert to pdf/docx/txt\");\n}","typeGuard":null,"tryCatchPattern":"try {\n    docs = pipeline.parse(document, format);\n} catch (IllegalArgumentException e) {\n    if (e.getMessage() != null && e.getMessage().startsWith(\"unsupported format\")) {\n        // reject upload or convert file before indexing\n    }\n}","preventionTips":["Whitelist allowed file extensions at upload time in the UI and API.","Derive format from a trusted source (stored metadata), not just file extension.","Document the supported format list for knowledge-base uploads."],"tags":["rag","file-format","indexing","unsupported"],"backgroundTag":"unsupported-operation","analyzedSha":"f82da0b50f35744c13968191be2b1cd2452ef550","analyzedAt":"2026-09-09T15:32:42.421Z","contentChangedAt":"2026-09-09T15:32:42.421Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}