alibaba/spring-ai-alibaba · error · UnsupportedOperationException
unsupported document type: ${documentType}
Error message
unsupported document type: ${documentType} What it means
KnowledgeRetrievalNodeSection.render throws UnsupportedOperationException when mapping a document's path value because documentType is not FILE or URL. The generator's switch only knows these two document kinds.
Source
Thrown at spring-ai-alibaba-admin/spring-ai-alibaba-admin-server-start/src/main/java/com/alibaba/cloud/ai/studio/admin/builder/generator/service/generator/workflow/sections/KnowledgeRetrievalNodeSection.java:117
// 安全检查:确保解析后的路径仍在允许的目录范围内
if (!resolvedPath.startsWith(p.normalize())) {
throw new SecurityException("非法路径访问尝试: " + document.getPath());
}
yield resolvedPath.toAbsolutePath().toString();
}
}
case URL -> {
// 对URL路径进行基本验证
String urlPath = document.getPath();
if (urlPath == null || urlPath.trim().isEmpty()) {
throw new IllegalArgumentException("URL路径不能为空");
}
yield urlPath;
}
default ->
throw new UnsupportedOperationException("unsupported document type: " + documentType);
};
String fileName = document.getName();
// 构造文件记录
return new ResourceFile(fileName, switch (documentType) {
case FILE -> ResourceFile.Type.CLASS_PATH;
case URL -> ResourceFile.Type.URL;
default ->
throw new UnsupportedOperationException("unsupported document type: " + documentType);
}, () -> {
try {
return Files.newInputStream(Path.of(path));
}
catch (IOException e) {
throw new RuntimeException(e);
}
});
})
.toList();View on GitHub (pinned to f82da0b50f)
Solutions
- Set documentType to FILE or URL for each document in the knowledge-retrieval node data
- Add a case for the new document type in both switches in KnowledgeRetrievalSection.render if you own the code
- Normalize/upgrade the DSL to a schema version the generator supports
Example fix
// before
{"type": "S3"}
// after
{"type": "URL", "path": "https://example.com/doc.pdf"} Defensive patterns
Strategy: validation
Validate before calling
Set<String> allowed = Set.of("FILE", "URL"); if (doc.getType() != null && !allowed.contains(doc.getType().name())) { throw new IllegalArgumentException("Unsupported document type: " + doc.getType()); } Type guard
boolean isSupportedDocType(DocumentType t) { return t == DocumentType.FILE || t == DocumentType.URL; } Try / catch
try { render(...); } catch (UnsupportedOperationException e) { log.error("Document type unsupported by generator: {}", e.getMessage()); } Prevention
- Normalize document types to the generator's supported set on DSL import
- Keep DSL schema versions and generator in sync
- Reject unknown types at DSL ingestion time
When it happens
Trigger: document.getType() on a knowledge-retrieval document resolves to an enum value other than FILE or URL (or a case label mismatch after a DSL dialect change) when rendering the node.
Common situations: A new document type added to the DSL schema but not to the generator's switch; corrupted or future-version DSL files; dialect-specific type names not normalized before generation.
Related errors
- URL路径不能为空
- Tool message not supported
- Unknown experiment status code: ${code}
- Unknown dataset status code:
- JumpTo value cannot be null
AI-assisted analysis of alibaba/spring-ai-alibaba@f82da0b50f (2026-09-09).
Data as JSON: /api/errors/8b19f234e4b9dbbc.
Report an issue: GitHub.