alibaba/spring-ai-alibaba · error · BizException
INVALID_PARAMS
INVALID_PARAMS
Error message
Short term memory schema is invalid
What it means
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.
Source
Thrown at spring-ai-alibaba-admin/spring-ai-alibaba-admin-server-core/src/main/java/com/alibaba/cloud/ai/studio/core/workflow/processor/AbstractExecuteProcessor.java:969
if (value instanceof Message) {
resultList.add((Message) value);
}
else {
Map<Object, Object> messageMap = JsonUtils.fromJsonToMap(JsonUtils.toJson(value));
if (messageMap != null) {
String role = MapUtils.getString(messageMap, "role");
String content = MapUtils.getString(messageMap, "content");
if (MessageRole.USER.getValue().equals(role)) {
resultList.add(new UserMessage(content));
}
else if (MessageRole.ASSISTANT.getValue().equals(role)) {
resultList.add(new AssistantMessage(content));
}
else if (MessageRole.SYSTEM.getValue().equals(role)) {
resultList.add(new SystemMessage(content));
}
else {
throw new BizException(ErrorCode.INVALID_PARAMS.toError("short term memory",
"Short term memory schema is invalid"));
}
}
}
}
}
}
return resultList;
}
}
/**
* Converts Spring AI messages to chat messages.
* @param messages List of Spring AI messages
* @return List of chat messages
*/
protected List<ChatMessage> convertToChatMessage(List<Message> messages) {
return messages.stream().map(message -> {View on GitHub (pinned to f82da0b50f)
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
Example fix
// before
{"role":"tool","content":"..."}
// after
{"role":"assistant","content":"..."} Defensive patterns
Strategy: validation
Validate before calling
for (Map<String, Object> msg : memoryMessages) {
String role = (String) msg.get("role");
if (!Set.of("user", "assistant", "system").contains(role)) {
throw new IllegalStateException("Unsupported memory role: " + role);
}
} Type guard
static boolean isValidMemoryRole(String role) {
return "user".equals(role) || "assistant".equals(role) || "system".equals(role);
} Try / catch
try {
processor.execute(graph, node, context);
} catch (BizException e) {
if (ErrorCode.INVALID_PARAMS.getCode().equals(e.getCode()) && e.getMessage().contains("short term memory")) {
log.error("Purge malformed memory entries for this conversation");
}
throw e;
} Prevention
- Validate role values when writing short-term memory
- Migrate legacy 'tool'/'function' roles to supported values
- Add a schema test for memory record format
When it happens
Trigger: 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.
Common situations: 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.
Understand the failure class
Background: Schema validation failed / invalid input schema: payload rejected because its shape doesn't match the expected schema — this error's family across 28 libraries.
Related errors
- MISSING_PARAMS
- UNAUTHORIZED
- Type "token" is not allowed.
- Parameter Not Allow Object Type
- WORKFLOW_RUN_CANCEL
AI-assisted analysis of alibaba/spring-ai-alibaba@f82da0b50f (2026-09-09).
Data as JSON: /api/errors/3aff48ef5607488e.
Report an issue: GitHub.