Bug description
When Anthropic's API returns an error the models/spring-ai-anthropic/src/main/java/org/springframework/ai/anthropic/api/StreamHelper.java
eventToChatCompletionResponse
method can throw a NPE because contentBlockReference
contains a null reference.
Environment
Java 21
Spring AI 1.0.0 (using the bom for dependency management) specifically in spring-ai-starter-model-anthropic
Steps to reproduce
Hard to reproduce - best I could do is force lots of requests to anthropic and wait for the ErrorEvent[type=ERROR, error=Error[type=overloaded_error, message=Overloaded]]
Here's a screenshot from a breakpoint that I used to find the error:
Comment From: ilayaperumalg
@adase11 Thanks for reporting the issue.