question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[Bug] Deserialization of IntegrationEvent

See original GitHub issue

Possible Issue

Deserialization of IntegrationEvent based classes won’t assign the same Id and CreationDate properties of the published events.

Example

From my understanding based on the current implementation of the IntegrationEvent those properties being { get; } only will not be populated by the current deserialization provided by the event bus implementations (AzureServiceBus and RabbitMQ) but instead get new values based on the constructor (issue link on Newtonsoft.Json project).

IntegrationEvent snippet

public class IntegrationEvent
{
    public IntegrationEvent()
    {
        Id = Guid.NewGuid();
        CreationDate = DateTime.UtcNow;
    }

    public Guid Id  { get; }
    public DateTime CreationDate { get; }
}

deserialization snippet

var integrationEvent = JsonConvert.DeserializeObject(message, eventType);

Question

Is this an unintended behavior (bug) or an integration event is by design supposed to have a new Id and CreationDate whenever it gets within the context of a microservice (subscriber)?.

– Best regards, Diogo Pinho

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:5

github_iconTop GitHub Comments

2reactions
mvelosopcommented, Aug 8, 2018

Hi @Diggzinc, this is actually a bug.

We intent to fix it this way to minimize changes and still keep the class immutable (in practice) and also “extend” this “immutability” implementation to the derived events:

public class IntegrationEvent
{
  public IntegrationEvent()
  {
    Id = Guid.NewGuid();
    CreationDate = DateTime.UtcNow;
  }

  [JsonProperty]
  public Guid Id { get; private set; }
  [JsonProperty]
  public DateTime CreationDate { get; private set; }
}

This solves the issue from the deserializer perspective, as it can find its way through the private setter, but has to be tested in the real app to be sure it works as expected.

Hope this helps in the meantime.

0reactions
mvelosopcommented, Jan 8, 2019

Closing this issue as it was solved with commit 06de1b68e3a758c854084200924c7e0799aa8b53

Read more comments on GitHub >

github_iconTop Results From Across the Web

Deserialization Bugs in the Wild
Insecure deserialization is a type of vulnerability that arises when an attacker is able to manipulate the serialized object and cause ...
Read more >
SDK Documentation Explorer
Developer-focused guides, tutorials, API Documentation, videos, and more for Genesys Cloud.
Read more >
Events not working with after Deserialization
What's happening is that the deserialized object no longer has the handler attached. You cannot serialize or deserialize event handlers; at the ...
Read more >
All Classes (Spring Integration 5.5.11 API)
A strategy to build an ErrorMessage based on the provided Throwable and AttributeAccessor as a context. ErrorMessageUtils. Utilities for building error messages ...
Read more >
Function error logged - ERP 10
This simple deserializes a string which looks something like this depending on the order submitted: "productList": "[\r\n{\"PartNum\": \" ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found