alibaba/spring-ai-alibaba · error · IllegalArgumentException

unsupported format:

Error message

unsupported format: 

What it means

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.

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:122

			}
			case "doc", "docx", "ppt", "pptx": {
				DocumentReader reader = new TikaDocumentReader(new FileSystemResource(file));
				documents = reader.get();
				break;
			}
			case "md", "markdown": {
				DocumentReader reader = new MarkdownDocumentReader(new FileSystemResource(file),
						MarkdownDocumentReaderConfig.defaultConfig());
				documents = reader.get();
				break;
			}
			case "txt": {
				DocumentReader reader = new TextDocumentReader(new FileSystemResource(file));
				documents = reader.get();
				break;
			}
			default:
				throw new IllegalArgumentException("unsupported format: " + format);
		}

		log.info("{} documents parsed", documents.size());

		return documents;
	}

	/**
	 * Transforms documents by splitting them into chunks
	 * @param documents Documents to transform
	 * @param processConfig Configuration for the transformation process
	 * @return List of transformed documents
	 */
	public List<Document> transform(List<Document> documents, ProcessConfig processConfig) {

		// TODO now use this simple chunk splitter first
		ChunkType chunkType = processConfig.getChunkType();
		TextSplitter splitter = null;

View on GitHub (pinned to f82da0b50f)

Solutions

  1. Convert the document to a supported format (pdf, docx, or txt) before uploading.
  2. Verify the document's format field is set correctly and matches the actual file.
  3. Add a new case with an appropriate DocumentReader if you need to support additional formats.

Example fix

// before
default:
    throw new IllegalArgumentException("unsupported format: " + format);
// after
case "md": {
    DocumentReader reader = new TextDocumentReader(new FileSystemResource(file));
    documents = reader.get();
    break;
}
default:
    throw new IllegalArgumentException("unsupported format: " + format);
Defensive patterns

Strategy: validation

Validate before calling

// Java
Set<String> supported = Set.of("pdf", "docx", "txt");
if (format == null || !supported.contains(format.toLowerCase())) {
    throw new IllegalArgumentException("Format " + format + " is not supported; convert to pdf/docx/txt");
}

Try / catch

try {
    docs = pipeline.parse(document, format);
} catch (IllegalArgumentException e) {
    if (e.getMessage() != null && e.getMessage().startsWith("unsupported format")) {
        // reject upload or convert file before indexing
    }
}

Prevention

When it happens

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

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

Understand the failure class

Background: UnsupportedOperationException and "is not supported" errors: when a library deliberately refuses a call — this error's family across 30 libraries.

Related errors


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