{"record":{"id":"d611d152b9eb3e06","repo":"spring-projects/spring-ai","slug":"s-messages-are-not-supported","errorCode":null,"errorMessage":"%s messages are not supported","messagePattern":"(.+?) messages are not supported","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"memory-repositories/spring-ai-model-chat-memory-repository-neo4j/src/main/java/org/springframework/ai/chat/memory/repository/neo4j/Neo4jChatMemoryRepository.java","lineNumber":116,"sourceCode":"\t\t\t\t\tmessage = buildUserMessage(record, messageMap, mediaList);\n\t\t\t\t}\n\t\t\t\telse if (msgType.equals(MessageType.ASSISTANT.getValue())) {\n\t\t\t\t\tmessage = buildAssistantMessage(record, messageMap, mediaList);\n\t\t\t\t}\n\t\t\t\telse if (msgType.equals(MessageType.SYSTEM.getValue())) {\n\t\t\t\t\tSystemMessage.Builder systemMessageBuilder = SystemMessage.builder()\n\t\t\t\t\t\t.text(MessageAttributes.TEXT_CONTENT.stringFrom(messageMap));\n\t\t\t\t\tif (!record.get(\"metadata\").isNull()) {\n\t\t\t\t\t\tMap<String, Object> retrievedMetadata = record.get(\"metadata\").asMap();\n\t\t\t\t\t\tsystemMessageBuilder.metadata(retrievedMetadata);\n\t\t\t\t\t}\n\t\t\t\t\tmessage = systemMessageBuilder.build();\n\t\t\t\t}\n\t\t\t\telse if (msgType.equals(MessageType.TOOL.getValue())) {\n\t\t\t\t\tmessage = buildToolMessage(record);\n\t\t\t\t}\n\t\t\t\tif (message == null) {\n\t\t\t\t\tthrow new IllegalArgumentException(\"%s messages are not supported\"\n\t\t\t\t\t\t.formatted(record.get(MessageAttributes.MESSAGE_TYPE.getValue()).asString()));\n\t\t\t\t}\n\t\t\t\tmessage.getMetadata().put(\"messageType\", message.getMessageType());\n\t\t\t\treturn message;\n\t\t\t}, Collectors.toList()));\n\n\t}\n\n\t@Override\n\tpublic void saveAll(String conversationId, List<Message> messages) {\n\t\t// First delete existing messages for this conversation\n\t\tdeleteByConversationId(conversationId);\n\n\t\t// Then add the new messages\n\t\ttry (Session s = this.config.getDriver().session()) {\n\t\t\ts.executeWriteWithoutResult(tx -> {\n\t\t\t\tfor (Message m : messages) {\n\t\t\t\t\taddMessageToTransaction(tx, conversationId, m);","sourceCodeStart":98,"sourceCodeEnd":134,"githubUrl":"https://github.com/spring-projects/spring-ai/blob/98a7beda4f29d80a71c5837eb4053b03a93a46f7/memory-repositories/spring-ai-model-chat-memory-repository-neo4j/src/main/java/org/springframework/ai/chat/memory/repository/neo4j/Neo4jChatMemoryRepository.java#L98-L134","documentation":"Neo4jChatMemoryRepository.findByConversationId() builds Message objects from query records. TOOL records are built via buildToolMessage but are not supported as returned messages in this path; when the resulting message is null the repository throws IllegalArgumentException naming the unsupported type. Essentially TOOL-typed rows cannot be materialized here.","triggerScenarios":"A conversation in Neo4j contains a node whose messageType is TOOL (or otherwise yields a null message), and findByConversationId is called on that conversation.","commonSituations":"Tool-call results were persisted by custom code or an older/other tool into the message nodes; mixed-version data; manual graph inserts.","solutions":["Remove or re-type the TOOL message nodes for that conversation","Keep TOOL interactions out of the persisted history (filter before saving)","Upgrade/align library versions if TOOL support changed between releases"],"exampleFix":"// before\nMATCH (m:Message {conversationId:'c1', messageType:'TOOL'}) // read throws IAE\n// after\nMATCH (m:Message {conversationId:'c1'}) WHERE m.messageType <> 'TOOL' RETURN m","handlingStrategy":"validation","validationCode":"// before reading, ensure no TOOL-typed nodes exist for the conversation\n// MATCH (m:Message {conversationId:$id, messageType:'TOOL'}) RETURN count(m) == 0","typeGuard":null,"tryCatchPattern":"try { messages = repo.findByConversationId(id); }\ncatch (IllegalArgumentException e) { messages = List.of(); logger.warn(\"Conversation contains unsupported message nodes\", e); }","preventionTips":["Filter TOOL interactions out before saving history","Don't write message nodes with custom code into the repository's graph","Align library versions across services using the same Neo4j database"],"tags":["neo4j","chat-memory","message-type","illegal-argument"],"backgroundTag":"unsupported-enum-value","analyzedSha":"98a7beda4f29d80a71c5837eb4053b03a93a46f7","analyzedAt":"2026-09-11T14:15:49.441Z","contentChangedAt":"2026-09-11T14:15:49.441Z","schemaVersion":2},"datasetVersion":"2026-09-14T11:17:12.474Z"}