The Document class in the spring-ai library has a potential bug in its JSON deserialization. When a Document instance is created from JSON and the content field is missing or null, it results in text being null. This leads to an assertion failure due to the following condition:
Assert.isTrue(text != null ^ media != null, "exactly one of text or media must be specified");
However, the Document class does not actually define a content field. Instead, it maps content to text using @JsonProperty("content"), which can cause unintended behavior.
Comment From: mboros1
This bug still exists today, @liuzhiguai thank you for surfacing it and renaming the json field from "text" to "content" does allow it to deserialize