{"record":{"id":"3aff48ef5607488e","repo":"alibaba/spring-ai-alibaba","slug":"invalid-params-3aff48","errorCode":"INVALID_PARAMS","errorMessage":"Short term memory schema is invalid","messagePattern":"Short term memory schema is invalid","errorType":"error_code","errorClass":"BizException","httpStatus":null,"severity":"error","filePath":"spring-ai-alibaba-admin/spring-ai-alibaba-admin-server-core/src/main/java/com/alibaba/cloud/ai/studio/core/workflow/processor/AbstractExecuteProcessor.java","lineNumber":969,"sourceCode":"\t\t\t\t\t\tif (value instanceof Message) {\n\t\t\t\t\t\t\tresultList.add((Message) value);\n\t\t\t\t\t\t}\n\t\t\t\t\t\telse {\n\t\t\t\t\t\t\tMap<Object, Object> messageMap = JsonUtils.fromJsonToMap(JsonUtils.toJson(value));\n\t\t\t\t\t\t\tif (messageMap != null) {\n\t\t\t\t\t\t\t\tString role = MapUtils.getString(messageMap, \"role\");\n\t\t\t\t\t\t\t\tString content = MapUtils.getString(messageMap, \"content\");\n\t\t\t\t\t\t\t\tif (MessageRole.USER.getValue().equals(role)) {\n\t\t\t\t\t\t\t\t\tresultList.add(new UserMessage(content));\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\telse if (MessageRole.ASSISTANT.getValue().equals(role)) {\n\t\t\t\t\t\t\t\t\tresultList.add(new AssistantMessage(content));\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\telse if (MessageRole.SYSTEM.getValue().equals(role)) {\n\t\t\t\t\t\t\t\t\tresultList.add(new SystemMessage(content));\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\telse {\n\t\t\t\t\t\t\t\t\tthrow new BizException(ErrorCode.INVALID_PARAMS.toError(\"short term memory\",\n\t\t\t\t\t\t\t\t\t\t\t\"Short term memory schema is invalid\"));\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\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\treturn resultList;\n\t\t}\n\t}\n\n\t/**\n\t * Converts Spring AI messages to chat messages.\n\t * @param messages List of Spring AI messages\n\t * @return List of chat messages\n\t */\n\tprotected List<ChatMessage> convertToChatMessage(List<Message> messages) {\n\t\treturn messages.stream().map(message -> {","sourceCodeStart":951,"sourceCodeEnd":987,"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/workflow/processor/AbstractExecuteProcessor.java#L951-L987","documentation":"While reconstructing chat history from short-term memory, AbstractExecuteProcessor maps each stored message role (user/assistant/system) to a Spring AI Message type. A role outside these values throws BizException INVALID_PARAMS because the short-term memory schema is invalid.","triggerScenarios":"Short-term memory content contains a message with an unrecognized 'role' value (anything other than user/assistant/system), encountered while building resultList for an LLM node.","commonSituations":"Memory records written by custom code or an older schema with roles like 'tool' or 'function'; corrupted memory entries in Redis/DB; manual insertion of memory rows.","solutions":["Inspect the stored short-term memory entries and correct unknown role values to user/assistant/system","Migrate or delete memory records written with non-standard roles; map 'tool'/'function' roles to the supported set or drop them","Harden the writer side to validate role values before persisting memory"],"exampleFix":"// before\n{\"role\":\"tool\",\"content\":\"...\"}\n// after\n{\"role\":\"assistant\",\"content\":\"...\"}","handlingStrategy":"validation","validationCode":"for (Map<String, Object> msg : memoryMessages) {\n    String role = (String) msg.get(\"role\");\n    if (!Set.of(\"user\", \"assistant\", \"system\").contains(role)) {\n        throw new IllegalStateException(\"Unsupported memory role: \" + role);\n    }\n}","typeGuard":"static boolean isValidMemoryRole(String role) {\n    return \"user\".equals(role) || \"assistant\".equals(role) || \"system\".equals(role);\n}","tryCatchPattern":"try {\n    processor.execute(graph, node, context);\n} catch (BizException e) {\n    if (ErrorCode.INVALID_PARAMS.getCode().equals(e.getCode()) && e.getMessage().contains(\"short term memory\")) {\n        log.error(\"Purge malformed memory entries for this conversation\");\n    }\n    throw e;\n}","preventionTips":["Validate role values when writing short-term memory","Migrate legacy 'tool'/'function' roles to supported values","Add a schema test for memory record format"],"tags":["workflow","memory","schema-validation"],"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"}