{"record":{"id":"cad2c3e4fcb05e18","repo":"alibaba/spring-ai-alibaba","slug":"invalid-data-format","errorCode":null,"errorMessage":"Invalid data format","messagePattern":"Invalid data format","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":500,"severity":"warning","filePath":"spring-ai-alibaba-admin/spring-ai-alibaba-admin-server-core/src/main/java/com/alibaba/cloud/ai/studio/core/agent/BasicAgentExecutor.java","lineNumber":438,"sourceCode":"\t\t\t\tswitch (item.getType()) {\n\t\t\t\t\tcase TEXT -> text = item.getText();\n\t\t\t\t\tcase IMAGE -> {\n\t\t\t\t\t\tif (StringUtils.isNotBlank(item.getUrl())) {\n\t\t\t\t\t\t\tString contentType = FileUtils.getContentType(item.getUrl());\n\t\t\t\t\t\t\tMediaType mediaType = MediaType.parseMediaType(contentType);\n\t\t\t\t\t\t\tmedia.add(Media.builder().mimeType(mediaType).data(new URL(item.getUrl())).build());\n\t\t\t\t\t\t}\n\t\t\t\t\t\telse if (StringUtils.isNotBlank(item.getPath())) {\n\t\t\t\t\t\t\tString contentType = FileUtils.getContentType(item.getPath());\n\t\t\t\t\t\t\tMediaType mediaType = MediaType.parseMediaType(contentType);\n\t\t\t\t\t\t\tResource resource = fileManager.loadFile(item.getPath());\n\t\t\t\t\t\t\tmedia.add(new Media(mediaType, resource));\n\t\t\t\t\t\t}\n\t\t\t\t\t\telse if (StringUtils.isNotBlank(item.getData())) {\n\t\t\t\t\t\t\t// format should be data:image/png;base64,iVBORw0KGgoSUhEUgAAA\n\t\t\t\t\t\t\tint semicolonIndex = item.getData().indexOf(';');\n\t\t\t\t\t\t\tif (semicolonIndex == -1) {\n\t\t\t\t\t\t\t\tthrow new IllegalArgumentException(\"Invalid data format\");\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\tString mimeType = item.getData().substring(0, semicolonIndex);\n\t\t\t\t\t\t\tMediaType mediaType = MediaType.parseMediaType(mimeType);\n\t\t\t\t\t\t\tmedia.add(new Media(mediaType, new ByteArrayResource(item.getData().getBytes())));\n\t\t\t\t\t\t}\n\t\t\t\t\t\telse {\n\t\t\t\t\t\t\tthrow new BizException(ErrorCode.INVALID_PARAMS.toError(\"content\",\n\t\t\t\t\t\t\t\t\t\"image content must be url or path or data\"));\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tcatch (MalformedURLException e) {\n\t\t\tthrow new RuntimeException(e);\n\t\t}\n","sourceCodeStart":420,"sourceCodeEnd":456,"githubUrl":"https://github.com/alibaba/spring-ai-alibaba/blob/f82da0b50f35744c13968191be2b1cd2452ef550/spring-ai-alibaba-admin/spring-ai-alibaba-admin-server-core/src/main/java/com/alibaba/cloud/ai/studio/core/agent/BasicAgentExecutor.java#L420-L456","documentation":"Warning logged in RoutingNode.getDecisionWithRetry when an LLM routing decision parses successfully but contains at least one agent name that is not among the configured subagents (invalidAgents non-empty). The invalid names are recorded in lastInvalidDecision so the next retry can include corrective feedback.","triggerScenarios":"decision.getAgentNames() returns names that fail validation against subAgents.stream().map(Agent::name); logged per failed attempt from apply().","commonSituations":"Model hallucinating plausible-but-unregistered agent names; typos or casing differences between prompt and registered subagent names; renaming a subagent without updating routing instructions.","solutions":["Make subagent names exactly match the names referenced in the routing instruction","Filter/whitelist model output to known subagent names before validation","Provide few-shot examples in the instruction showing only valid names","Add a fallback agent for graceful degradation"],"exampleFix":"// before\n.subAgents(List.of(codingAgent)) // prompt tells model to route to \"coder\"\n// after\n.subAgents(List.of(codingAgent)) // prompt now says: route to \"codingAgent\"","handlingStrategy":"validation","validationCode":"List<String> validNames = subAgents.stream().map(Agent::name).toList();\nSet<String> valid = new java.util.HashSet<>(validNames);\nList<String> requested = decision.getAgentNames();\nList<String> invalid = requested.stream().filter(n -> !valid.contains(n)).toList();\nif (!invalid.isEmpty()) log.warn(\"Decision names not registered: {} valid={}\", invalid, validNames);","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Keep agent names in one constant list used by both registration and prompts","Avoid renaming subagents without updating routing instructions","Whitelist/sanitize model output names before routing"],"tags":["routing-agent","invalid-agent-name","llm-output","schema-validation-failed"],"backgroundTag":"schema-validation-failed","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"}