Skip to content

[Bug]:io.agentscope.core.event.AgentEvent Deserialize error #1948

Description

@wanna280

Describe the bug

When streaming AgentStartEvent (and likely other events from io.agentscope.core.event) via Spring MVC's ResponseBodyEmitter / SseEmitter, Jackson 3 (tools.jackson.databind) throws
an InvalidDefinitionException during serialization. The root cause is a conflict between the @JsonTypeInfo type-id property named type and a bean property with the same name on
the event class. The same SSE endpoint works fine for plain String/JSON-POJO payloads, so the issue is specific to AgentScope's event classes.

To Reproduce

Steps to reproduce the behavior:

  1. Build a Spring Boot controller that returns an SseEmitter and inside it send() an io.agentscope.core.event.AgentStartEvent instance, e.g.:

@GetMapping(value = "/chat/stream", produces = MediaType.TEXT_EVENT_STREAM_VALUE)
public SseEmitter chat() {
SseEmitter emitter = new SseEmitter();
emitter.send(new AgentStartEvent(...)); // fails here
emitter.complete();
return emitter;
}
2. Execute: curl http://localhost:8080/chat/stream
3. See error: HttpMessageConversionException → InvalidDefinitionException: Conflict between type id property 'type' and bean property with same name

Expected behavior

AgentStartEvent (and sibling event classes in io.agentscope.core.event) should serialize to JSON without raising a InvalidDefinitionException. Either:

  • The @JsonTypeInfo annotation on the event base class should use JsonTypeInfo.As.EXISTING_PROPERTY (or As.EXTERNAL_PROPERTY) so the type id is not duplicated as a synthetic
    property, or
  • The concrete event class should not declare a bean property named type (rename it, or annotate it with @JsonProperty/@JsonIgnore appropriately), or
  • A mixin / custom ObjectMapper configuration should be provided to resolve the conflict.

Error messages

java.lang.IllegalStateException: Failed to send [...]
at org.springframework.web.servlet.mvc.method.annotation.ResponseBodyEmitter.sendInternal(ResponseBodyEmitter.java:259)
at org.springframework.web.servlet.mvc.method.annotation.ResponseBodyEmitterReturnValueHandler.handleReturnValue(...)

Caused by: org.springframework.http.converter.HttpMessageConversionException: Type definition error: [simple type, class io.agentscope.core.event.AgentStartEvent]
at org.springframework.http.converter.AbstractJacksonHttpMessageConverter.writeInternal(AbstractJacksonHttpMessageConverter.java:441)

Caused by: tools.jackson.databind.exc.InvalidDefinitionException: Conflict between type id property 'type' and bean property with same name; consider using
JsonTypeInfo.As.EXISTING_PROPERTY to avoid duplication
at [No location information]
at tools.jackson.databind.exc.InvalidDefinitionException.from(InvalidDefinitionException.java:80)
at tools.jackson.databind.ser.BeanSerializerFactory._verifyNoTypeIdPropertyConflict(BeanSerializerFactory.java:838)
at tools.jackson.databind.ser.BeanSerializerFactory.constructBeanOrAddOnSerializer(BeanSerializerFactory.java:345)
...

The key line is:

Conflict between type id property 'type' and bean property with same name; consider using JsonTypeInfo.As.EXISTING_PROPERTY to avoid duplication

Environment

  • AgentScope-Java Version: 2.0.0-RC3
  • Spring Boot Version: 4.1.0
  • Jackson Version: Jackson 3 (tools.jackson.databind)
  • Java Version: 21
  • OS: macOS

Additional context

  • The endpoint is consumed through Spring MVC's ResponseBodyEmitterReturnValueHandler, which uses the Spring-managed ObjectMapper (Jackson 3). The exception is raised at
    serialization time inside BeanSerializerFactory._verifyNoTypeIdPropertyConflict, before any bytes are written to the SSE stream.
  • This strongly suggests the AgentStartEvent type hierarchy uses @JsonTypeInfo(use = Id.NAME, include = As.PROPERTY, property = "type") (the default-style configuration) while a
    subclass also exposes a getter/setter or field literally named type, producing two distinct property nodes for the same JSON key type. Jackson 3 is stricter about this than
    Jackson 2 and rejects it at serializer construction.
  • Suggested fix: change include = As.PROPERTY to include = As.EXISTING_PROPERTY (and make sure the type field is populated), or remove/rename the conflicting bean property on the
    event subclass. A reproduction project can be provided if needed.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    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