Bug description Running code that creates embeddings and writes them to a Chroma vector store. Code works, but if I upgrade the app from Spring Boot 3.3.4 to 3.4.1, the write fails with:

2024-12-29T11:37:29.960-06:00 ERROR 72456 --- [legweb] [         task-1] .a.i.SimpleAsyncUncaughtExceptionHandler : Unexpected exception occurred invoking async method: public void org.knowyourgov.legweb.bill.BillIndexService.embed(java.lang.String)

org.springframework.web.client.HttpClientErrorException$UnprocessableEntity: 422 Unprocessable Entity: "{"detail":[{"type":"missing","loc":["body"],"msg":"Field required","input":null}]}"
    at org.springframework.web.client.HttpClientErrorException.create(HttpClientErrorException.java:133) ~[spring-web-6.2.1.jar:6.2.1]
    at org.springframework.web.client.StatusHandler.lambda$defaultHandler$3(StatusHandler.java:86) ~[spring-web-6.2.1.jar:6.2.1]
    at org.springframework.web.client.StatusHandler.handle(StatusHandler.java:146) ~[spring-web-6.2.1.jar:6.2.1]
    at org.springframework.web.client.DefaultRestClient$DefaultResponseSpec.applyStatusHandlers(DefaultRestClient.java:826) ~[spring-web-6.2.1.jar:6.2.1]
    at org.springframework.web.client.DefaultRestClient$DefaultResponseSpec.lambda$toBodilessEntity$3(DefaultRestClient.java:789) ~[spring-web-6.2.1.jar:6.2.1]
    at org.springframework.web.client.DefaultRestClient$DefaultRequestBodyUriSpec.exchangeInternal(DefaultRestClient.java:574) ~[spring-web-6.2.1.jar:6.2.1]
    at org.springframework.web.client.DefaultRestClient$DefaultRequestBodyUriSpec.exchange(DefaultRestClient.java:535) ~[spring-web-6.2.1.jar:6.2.1]
    at org.springframework.web.client.RestClient$RequestHeadersSpec.exchange(RestClient.java:677) ~[spring-web-6.2.1.jar:6.2.1]
    at org.springframework.web.client.DefaultRestClient$DefaultResponseSpec.executeAndExtract(DefaultRestClient.java:809) ~[spring-web-6.2.1.jar:6.2.1]
    at org.springframework.web.client.DefaultRestClient$DefaultResponseSpec.toBodilessEntity(DefaultRestClient.java:787) ~[spring-web-6.2.1.jar:6.2.1]
    at org.springframework.ai.chroma.vectorstore.ChromaApi.upsertEmbeddings(ChromaApi.java:182) ~[spring-ai-chroma-store-1.0.0-M5.jar:1.0.0-M5]
    at org.springframework.ai.chroma.vectorstore.ChromaVectorStore.doAdd(ChromaVectorStore.java:182) ~[spring-ai-chroma-store-1.0.0-M5.jar:1.0.0-M5]
    at org.springframework.ai.vectorstore.observation.AbstractObservationVectorStore.lambda$add$1(AbstractObservationVectorStore.java:91) ~[spring-ai-core-1.0.0-M5.jar:1.0.0-M5]
    at io.micrometer.observation.Observation.observe(Observation.java:498) ~[micrometer-observation-1.14.2.jar:1.14.2]
    at org.springframework.ai.vectorstore.observation.AbstractObservationVectorStore.add(AbstractObservationVectorStore.java:91) ~[spring-ai-core-1.0.0-M5.jar:1.0.0-M5]
    at org.springframework.ai.vectorstore.VectorStore.accept(VectorStore.java:53) ~[spring-ai-core-1.0.0-M5.jar:1.0.0-M5]
    at org.springframework.ai.vectorstore.VectorStore.accept(VectorStore.java:38) ~[spring-ai-core-1.0.0-M5.jar:1.0.0-M5]
    at org.springframework.ai.document.DocumentWriter.write(DocumentWriter.java:30) ~[spring-ai-core-1.0.0-M5.jar:1.0.0-M5]

Environment Spring AI 1.0.0-M5, ChromaDB 0.5.20

Expected behavior App should continue to work in Spring Boot 3.4.1

Minimal Complete Reproducible example Code snippet that triggers issue:

        Resource resource = new ByteArrayResource(billText.getFullText().getBytes());
        TextReader reader = new TextReader(resource);
        List<Document> split = tokenSplitter.split(reader.read());
        for (Document document : split) {
            document.getMetadata().put(BILL_METADATA, billText.getBillId());
        }
        vectorStore.write(split);

Comment From: Bofutw

I’m experiencing the same issue. Could it possibly be related to RestClient?

Comment From: ilayaperumalg

Hi @cpage-pivotal @Bofutw , It would be helpful to have a GitHub example to investigate this issue. I just tried to replicate the issue via this example and it works fine with Spring Boot 3.4.1. Let me know what's missing in my test to reproduce the issue. Thanks

Comment From: cpage-pivotal

This repo replicates the problem. Hit the /bill/text endpoint. Upgrade from Spring Boot 3.3.4 to Spring Boot 3.4.1 to trigger the bug.

https://github.com/cepage/spring-ai-chroma-bug

Comment From: markpollack

just a note - If you drop back to using Chroma 0.5.15 you are good with Spring Boot 3.4.1 and Spring AI 1.0.0-M5.

Comment From: ilayaperumalg

Closing this as invalid as I learnt the issue from the underlying code passed empty document list in some cases.

Comment From: cpage-pivotal

Just to clarify, the code only passed an empty document list in the case where you weren't able to replicate the bug. Specifically, the case where you only passed a String of 5 or fewer characters, like "hello".

The bug is reliably replicated in any real-world use case, where we are tokenizing a string that is longer than 5 characters in length.

Comment From: ilayaperumalg

@cpage-pivotal Could you try using the configuration spring.http.client.factory=simple to choose the SimpleClientHttpRequestFactory as I learnt from @making that this is required to change the default JDK HttpClient which Spring Boot 3.4 uses: https://github.com/spring-projects/spring-boot/wiki/Spring-Boot-3.4-Release-Notes#upgrading-from-spring-boot-33

Comment From: cpage-pivotal

That worked for me! Setting the factory to simple eliminated the problem.