{"record":{"id":"f40386d5a8754839","repo":"alibaba/spring-ai-alibaba","slug":"url","errorCode":null,"errorMessage":"URL路径不能为空","messagePattern":"URL路径不能为空","errorType":"validation","errorClass":"IllegalArgumentException","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":112,"sourceCode":"\t\t\t\t\tString path = switch (documentType) {\n\t\t\t\t\t\tcase FILE -> {\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tPath p = Path.of(studioStoragePath);\n\t\t\t\t\t\t\t\tPath resolvedPath = p.resolve(document.getPath()).normalize();\n\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) {","sourceCodeStart":94,"sourceCodeEnd":130,"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#L94-L130","documentation":"KnowledgeRetrievalNodeSection.render throws this IllegalArgumentException during code generation when a knowledge-retrieval document's type is URL but its path is null or blank. The generator requires a concrete URL to embed as the document source in the generated workflow code.","triggerScenarios":"A node of type KNOWLEDGE_RETRIEVAL in the DSL has a document whose documentType is URL and document.getPath() returns null or a whitespace-only string when render() is called.","commonSituations":"Importing a Dify/LangFlow DSL export where the URL field was never filled in; hand-edited DSL JSON with an empty \"path\"; API payloads created programmatically that omit path for URL-typed documents.","solutions":["Set a non-empty path (URL) on every URL-typed document in the knowledge-retrieval node data before generating code","Validate the DSL node data before invoking generation and reject documents with blank paths","Change the document type to FILE if it is actually a classpath resource, so the FILE branch is taken instead"],"exampleFix":"// before\ndocument.setType(\"URL\"); // path left null\n// after\ndocument.setType(\"URL\");\ndocument.setPath(\"https://example.com/doc.pdf\");","handlingStrategy":"validation","validationCode":"if (doc.getType() == DocumentType.URL && (doc.getPath() == null || doc.getPath().isBlank())) { throw new IllegalArgumentException(\"URL document requires a non-empty path: \" + doc.getName()); }","typeGuard":"boolean hasUrlPath(DslDocument d) { return d.getType() == DocumentType.URL && d.getPath() != null && !d.getPath().trim().isEmpty(); }","tryCatchPattern":"try { section.render(node, varName); } catch (IllegalArgumentException e) { log.error(\"Invalid knowledge-retrieval document: {}\", e.getMessage()); }","preventionTips":["Validate all document paths before submitting the DSL for generation","Require URL field in forms for URL-typed documents","Lint imported DSLs for blank path fields"],"tags":["java","code-generation","validation","empty-field"],"backgroundTag":"empty-required-field","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"}