Skip to content

No serializer found for class software.amazon.awssdk.services.bedrockruntime.model.TokenUsage #5682

@robert-niestroj

Description

@robert-niestroj

Bug description
After upgrade from Spring AI 1.1.2 to 1.1.3 following Exception is thrown:

com.fasterxml.jackson.databind.exc.InvalidDefinitionException: No serializer found for class software.amazon.awssdk.services.bedrockruntime.model.TokenUsage and no properties discovered to create BeanSerializer (to avoid exception, disable SerializationFeature.FAIL_ON_EMPTY_BEANS) (through reference chain: org.springframework.ai.chat.model.ChatResponse["metadata"]->org.springframework.ai.chat.metadata.ChatResponseMetadata["usage"]->org.springframework.ai.chat.metadata.DefaultUsage["nativeUsage"])
	at com.fasterxml.jackson.databind.exc.InvalidDefinitionException.from(InvalidDefinitionException.java:77) ``` 


in this code:

```java
  @GetMapping("/hello-response")
  public ChatResponse helloResponse(@RequestParam String prompt) {
    String promptFromDb = "Plan me a {days}-day trip to {city}";
    return chatClient
        .prompt()
        .user(u -> u.text(promptFromDb).param("days", 3).param("city", prompt))
        .call()
        .chatResponse();
  }

Environment
Java 25
Spring Boot 3.5
Spring AI 1.1.3
Amazon Bedrock Converse

Steps to reproduce
Execute above code.

Expected behavior
No exception is thrown like in Spring AI 1.1.2

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions