{"record":{"id":"b35e545277da79b7","repo":"alibaba/spring-ai-alibaba","slug":"unsupported-document-type","errorCode":null,"errorMessage":"unsupported document type: ","messagePattern":"unsupported document type: ","errorType":"exception","errorClass":"RuntimeException","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":90,"sourceCode":"\t * Parses documents based on their format (PDF, DOC, MD, TXT, etc.)\n\t * @param document The document to parse\n\t * @return List of parsed documents\n\t */\n\tpublic List<Document> parse(com.alibaba.cloud.ai.studio.runtime.domain.knowledgebase.Document document) {\n\t\tList<Document> documents;\n\t\tString format = document.getFormat();\n\n\t\tString path;\n\t\tif (document.getType() == DocumentType.OSS\n\t\t\t\t|| UploadType.OSS.getValue().equalsIgnoreCase(properties.getUploadMethod())) {\n\t\t\tpath = FileUtils.getTempFilePath(document.getDocId());\n\t\t\tossManager.downloadFile(document.getPath(), path);\n\t\t}\n\t\telse if (document.getType() == DocumentType.FILE) {\n\t\t\tpath = properties.getStoragePath() + File.separator + document.getPath();\n\t\t}\n\t\telse {\n\t\t\tthrow new RuntimeException(\"unsupported document type: \" + document.getType());\n\t\t}\n\n\t\tFile file = new File(path);\n\t\tif (!file.exists()) {\n\t\t\tthrow new RuntimeException(\"file does not exist, path: \" + path);\n\t\t}\n\n\t\tformat = StringUtils.lowerCase(format);\n\t\tswitch (format) {\n\t\t\tcase \"pdf\": {\n\t\t\t\tDocumentReader reader = new PagePdfDocumentReader(new FileSystemResource(file));\n\t\t\t\tdocuments = reader.get();\n\t\t\t\tbreak;\n\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;","sourceCodeStart":72,"sourceCodeEnd":108,"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#L72-L108","documentation":"KnowledgeBaseIndexPipeline.parse resolves the local file path for a document based on its type: OSS-stored documents are downloaded, FILE-type documents are read from the configured storage path, and any other DocumentType reaches an else branch that throws RuntimeException \"unsupported document type: \" + type. Only the two supported types can be indexed for parsing.","triggerScenarios":"Indexing a KnowledgeBase document whose DocumentType is neither OSS nor FILE (e.g. a newly introduced enum value, URL, or manually inserted DB row with a type the pipeline doesn't handle).","commonSituations":"Documents created through admin UI versions supporting a type that the indexing pipeline hasn't been updated for; data migrations inserting documents with null or legacy type values; custom DocumentType enum extensions.","solutions":["Re-create/re-upload the document with a supported type (OSS or FILE).","Check the document's type value in the database and correct it to a supported DocumentType.","Extend KnowledgeBaseIndexPipeline.parse to handle the new DocumentType if your build added one."],"exampleFix":"// before\nelse {\n    throw new RuntimeException(\"unsupported document type: \" + document.getType());\n}\n// after\nelse if (document.getType() == DocumentType.URL) {\n    path = downloadFromUrl(document.getPath());\n}\nelse {\n    throw new RuntimeException(\"unsupported document type: \" + document.getType());\n}","handlingStrategy":"validation","validationCode":"// Java\nif (document.getType() != DocumentType.OSS && document.getType() != DocumentType.FILE) {\n    throw new IllegalArgumentException(\"Document type \" + document.getType() + \" is not indexable\");\n}","typeGuard":null,"tryCatchPattern":"try {\n    pipeline.parse(document, format);\n} catch (RuntimeException e) {\n    if (e.getMessage() != null && e.getMessage().startsWith(\"unsupported document type\")) {\n        // mark document as failed with actionable reason\n    }\n}","preventionTips":["Restrict document uploads to supported types in the API/UI layer.","Keep DocumentType enum and the indexing pipeline in sync when adding types.","Validate document type when persisting KnowledgeBase records."],"tags":["rag","document-type","indexing"],"backgroundTag":"unsupported-enum-value","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"}