{"record":{"id":"8b19f234e4b9dbbc","repo":"alibaba/spring-ai-alibaba","slug":"unsupported-document-type-documenttype","errorCode":null,"errorMessage":"unsupported document type: ${documentType}","messagePattern":"unsupported document type: (.+?)","errorType":"exception","errorClass":"UnsupportedOperationException","httpStatus":null,"severity":"error","filePath":"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","lineNumber":117,"sourceCode":"\n\t\t\t\t\t\t\t\t// 安全检查：确保解析后的路径仍在允许的目录范围内\n\t\t\t\t\t\t\t\tif (!resolvedPath.startsWith(p.normalize())) {\n\t\t\t\t\t\t\t\t\tthrow new SecurityException(\"非法路径访问尝试: \" + document.getPath());\n\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\tyield resolvedPath.toAbsolutePath().toString();\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t\tcase URL -> {\n\t\t\t\t\t\t\t// 对URL路径进行基本验证\n\t\t\t\t\t\t\tString urlPath = document.getPath();\n\t\t\t\t\t\t\tif (urlPath == null || urlPath.trim().isEmpty()) {\n\t\t\t\t\t\t\t\tthrow new IllegalArgumentException(\"URL路径不能为空\");\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tyield urlPath;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tdefault ->\n\t\t\t\t\t\t\tthrow new UnsupportedOperationException(\"unsupported document type: \" + documentType);\n\t\t\t\t\t};\n\t\t\t\t\tString fileName = document.getName();\n\t\t\t\t\t// 构造文件记录\n\t\t\t\t\treturn new ResourceFile(fileName, switch (documentType) {\n\t\t\t\t\t\tcase FILE -> ResourceFile.Type.CLASS_PATH;\n\t\t\t\t\t\tcase URL -> ResourceFile.Type.URL;\n\t\t\t\t\t\tdefault ->\n\t\t\t\t\t\t\tthrow new UnsupportedOperationException(\"unsupported document type: \" + documentType);\n\t\t\t\t\t}, () -> {\n\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\treturn Files.newInputStream(Path.of(path));\n\t\t\t\t\t\t}\n\t\t\t\t\t\tcatch (IOException e) {\n\t\t\t\t\t\t\tthrow new RuntimeException(e);\n\t\t\t\t\t\t}\n\t\t\t\t\t});\n\t\t\t\t})\n\t\t\t\t.toList();","sourceCodeStart":99,"sourceCodeEnd":135,"githubUrl":"https://github.com/alibaba/spring-ai-alibaba/blob/f82da0b50f35744c13968191be2b1cd2452ef550/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#L99-L135","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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"],"exampleFix":"// before\n{\"type\": \"S3\"}\n// after\n{\"type\": \"URL\", \"path\": \"https://example.com/doc.pdf\"}","handlingStrategy":"validation","validationCode":"Set<String> allowed = Set.of(\"FILE\", \"URL\"); if (doc.getType() != null && !allowed.contains(doc.getType().name())) { throw new IllegalArgumentException(\"Unsupported document type: \" + doc.getType()); }","typeGuard":"boolean isSupportedDocType(DocumentType t) { return t == DocumentType.FILE || t == DocumentType.URL; }","tryCatchPattern":"try { render(...); } catch (UnsupportedOperationException e) { log.error(\"Document type unsupported by generator: {}\", e.getMessage()); }","preventionTips":["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"],"tags":["java","code-generation","enum","unsupported"],"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"}