alibaba/spring-ai-alibaba · error · RuntimeException

Unsupported Extension Type: {fileExtension}

Error message

Unsupported Extension Type: {fileExtension}

What it means

DocumentExtractorNode.extractTextByFileExtension looks up a parsing Function in an internal map keyed by lowercase file extension (pdf, docx, txt, html, etc.). If the extension is missing from the map — because the document format is not one of the built-in supported types — it throws this RuntimeException. It is a fail-fast guard against unsupported file formats rather than a parsing failure.

Source

Thrown at spring-boot-starters/spring-ai-alibaba-starter-builtin-nodes/src/main/java/com/alibaba/cloud/ai/graph/node/DocumentExtractorNode.java:162

			// Single file, add directly to the list
			fileList = List.of(fileObj.toString());
		}
		List<String> documentContents = this.getDocument(fileList);

		String key = Optional.ofNullable(this.outputKey).orElse("text");
		if (!this.inputIsArray) {
			return Map.of(key, documentContents.get(0));
		}
		else {
			return Map.of(key, documentContents);
		}
	}

	private String extractTextByFileExtension(InputStream fileContent, String fileExtension) {

		Function<InputStream, List<Document>> extractor = this.extractors.get(fileExtension);
		if (extractor == null) {
			throw new RuntimeException("Unsupported Extension Type: " + fileExtension);
		}

		return extractor.apply(fileContent).get(0).getText();
	}

	private String getFileExtension(String filePath) {
		Path path = Paths.get(filePath);
		String fileName = path.getFileName().toString();
		int dotIndex = fileName.lastIndexOf('.');

		return (dotIndex == -1) ? "" : fileName.substring(dotIndex + 1);
	}

	public static Builder builder() {
		return new Builder();
	}

	public static class Builder {

View on GitHub (pinned to f82da0b50f)

Solutions

  1. Convert the document to a supported format (PDF, DOCX, TXT, HTML) before extraction.
  2. Check the extension actually matches one of the registered extractors (inspect the extractors map keys in DocumentExtractorNode).
  3. Log/verify the value of getFileExtension(filePath) — strip leading dots and normalize case.
  4. Register a custom extractor for the extension in the extractors map if extending the node.
  5. Return a clear validation error to the workflow user before the node runs.

Example fix

// before
Function<InputStream, List<Document>> extractor = this.extractors.get(fileExtension);
if (extractor == null) {
    throw new RuntimeException("Unsupported Extension Type: " + fileExtension);
}
// after
String key = fileExtension == null ? "" : fileExtension.toLowerCase().replaceAll("^\\.", "");
Function<InputStream, List<Document>> extractor = this.extractors.get(key);
if (extractor == null) {
    throw new IllegalArgumentException("Unsupported Extension Type: " + key
        + "; supported: " + this.extractors.keySet());
}
Defensive patterns

Strategy: validation

Validate before calling

Set<String> supported = Set.of("pdf","docx","txt","html");
String ext = Optional.ofNullable(path)
    .map(p -> p.substring(p.lastIndexOf('.') + 1).toLowerCase())
    .orElse("");
if (!supported.contains(ext)) throw new IllegalStateException("Unsupported extension: " + ext);

Type guard

boolean isSupported(String ext) {
    return ext != null && extractors.containsKey(ext.toLowerCase().replaceAll("^\\.", ""));
}

Try / catch

try {
    String text = node.getDocument(state);
} catch (RuntimeException e) {
    if (e.getMessage().startsWith("Unsupported Extension Type")) {
        log.warn("Skipping unsupported document: {}", e.getMessage());
    } else throw e;
}

Prevention

When it happens

Trigger: Calling getDocument/extractTextByFileExtension with a file whose extension (or derived key) is not registered in the extractors map: e.g. .md, .csv, .pptx, .xlsx, .rtf, or a file with no extension at all; also a wrong/mispelled extension passed explicitly.

Common situations: Users point the DocumentExtractor node at knowledge-base files in formats outside the supported set (Markdown, CSV, PowerPoint); files uploaded without extensions; case or whitespace issues in the extension key.

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/03b09ff68eae5a2b. Report an issue: GitHub.