alibaba/spring-ai-alibaba · error · RuntimeException

unsupported document type:

Error message

unsupported document type: 

What it means

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.

Source

Thrown at spring-ai-alibaba-admin/spring-ai-alibaba-admin-server-core/src/main/java/com/alibaba/cloud/ai/studio/core/rag/indices/KnowledgeBaseIndexPipeline.java:90

	 * Parses documents based on their format (PDF, DOC, MD, TXT, etc.)
	 * @param document The document to parse
	 * @return List of parsed documents
	 */
	public List<Document> parse(com.alibaba.cloud.ai.studio.runtime.domain.knowledgebase.Document document) {
		List<Document> documents;
		String format = document.getFormat();

		String path;
		if (document.getType() == DocumentType.OSS
				|| UploadType.OSS.getValue().equalsIgnoreCase(properties.getUploadMethod())) {
			path = FileUtils.getTempFilePath(document.getDocId());
			ossManager.downloadFile(document.getPath(), path);
		}
		else if (document.getType() == DocumentType.FILE) {
			path = properties.getStoragePath() + File.separator + document.getPath();
		}
		else {
			throw new RuntimeException("unsupported document type: " + document.getType());
		}

		File file = new File(path);
		if (!file.exists()) {
			throw new RuntimeException("file does not exist, path: " + path);
		}

		format = StringUtils.lowerCase(format);
		switch (format) {
			case "pdf": {
				DocumentReader reader = new PagePdfDocumentReader(new FileSystemResource(file));
				documents = reader.get();
				break;
			}
			case "doc", "docx", "ppt", "pptx": {
				DocumentReader reader = new TikaDocumentReader(new FileSystemResource(file));
				documents = reader.get();
				break;

View on GitHub (pinned to f82da0b50f)

Solutions

  1. Re-create/re-upload the document with a supported type (OSS or FILE).
  2. Check the document's type value in the database and correct it to a supported DocumentType.
  3. Extend KnowledgeBaseIndexPipeline.parse to handle the new DocumentType if your build added one.

Example fix

// before
else {
    throw new RuntimeException("unsupported document type: " + document.getType());
}
// after
else if (document.getType() == DocumentType.URL) {
    path = downloadFromUrl(document.getPath());
}
else {
    throw new RuntimeException("unsupported document type: " + document.getType());
}
Defensive patterns

Strategy: validation

Validate before calling

// Java
if (document.getType() != DocumentType.OSS && document.getType() != DocumentType.FILE) {
    throw new IllegalArgumentException("Document type " + document.getType() + " is not indexable");
}

Try / catch

try {
    pipeline.parse(document, format);
} catch (RuntimeException e) {
    if (e.getMessage() != null && e.getMessage().startsWith("unsupported document type")) {
        // mark document as failed with actionable reason
    }
}

Prevention

When it happens

Trigger: 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).

Common situations: 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.

Related errors


AI-assisted analysis of alibaba/spring-ai-alibaba@f82da0b50f (2026-09-09). Data as JSON: /api/errors/b35e545277da79b7. Report an issue: GitHub.