Skip to content
This repository was archived by the owner on Dec 4, 2023. It is now read-only.
This repository was archived by the owner on Dec 4, 2023. It is now read-only.

Activity event with timetstamp not having milli seconds results in com.fasterxml.jackson.databind.exc.InvalidFormatException #1502

@harinandan-reddy

Description

@harinandan-reddy

Github issues should be used for bugs and feature requests. Use Stack Overflow for general "how-to" questions.

Version

4.14.2

Describe the bug

We some time receive activity event with timetstamp not having milli seconds like 2022-09-23T09:19:29Z which results in the following error

Resolved [org.springframework.http.converter.HttpMessageNotReadableException: JSON parse error: Cannot deserialize value of type `java.time.OffsetDateTime` from String "2022-09-23T09:19:29Z": Failed to deserialize java.time.OffsetDateTime: (java.time.format.DateTimeParseException) Text '2022-09-23T09:19:29Z' could not be parsed at index 19; nested exception is com.fasterxml.jackson.databind.exc.InvalidFormatException: Cannot deserialize value of type `java.time.OffsetDateTime` from String "2022-09-23T09:19:29Z": Failed to deserialize java.time.OffsetDateTime: (java.time.format.DateTimeParseException) Text '2022-09-23T09:19:29Z' could not be parsed at index 19 at [Source: (PushbackInputStream); line: 1, column: 57] (through reference chain: com.microsoft.bot.schema.Activity["timestamp"])]

To Reproduce

Steps to reproduce the behaviour:

Run the following unit test to reproduce the error

import static org.junit.jupiter.api.Assertions.assertNotNull;

import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.datatype.jsr310.JSR310Module;
import com.microsoft.bot.schema.Activity;
import java.io.IOException;
import org.junit.jupiter.api.Test;

class ActivityTest {

  @Test
  void testActivityDeserialize() throws IOException {
    ObjectMapper objectMapper = new ObjectMapper();
    objectMapper.registerModule(new JSR310Module());
    String json =
        "{\"fromStreamingConnection\":false,\"teamsActivity\":false,\"type\":\"message\",\"timestamp\":\"2022-09-23T09:19:29Z\",\"historyDisclosed\":false}";
    assertNotNull(objectMapper.readValue(json, Activity.class));
  }
}

Expected behaviour

The Activity object should be deserialised without any error

Screenshots

NA

Additional context

NA

Metadata

Metadata

Labels

Bot ServicesRequired for internal Azure reporting. Do not delete. Do not change color.bugIndicates an unexpected problem or an unintended behavior.customer-replied-toIndicates that the team has replied to the issue reported by the customer. Do not delete.customer-reportedIssue is created by anyone that is not a collaborator in the repository.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions