Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updates the MessageSerializer to store the json value as the actual json object in the data field. #190

Closed
wants to merge 5 commits into from

Conversation

GarrettBeatty
Copy link
Contributor

@GarrettBeatty GarrettBeatty commented Mar 14, 2025

Issue #, if available: #168

Description of changes:

  1. Updates the MessageSerializer to store the json value as the actual json object in the data field.
  2. Add datacontenttype field to message
  3. Right now its pointing to refactor2 branch since that PR to be merged first

Before

{
    "version": "0",
    "id": "359472c2-c66b-00df-5976-cef04c383a15",
    "detail-type": "Payload",
    "source": "/aws/messaging",
    "account": "147997163238",
    "time": "2025-03-14T18:40:58Z",
    "region": "us-east-1",
    "resources": [],
    "detail": {
        "id": "fdc50c90-f747-4794-ae91-d39894cc6442",
        "source": "/aws/messaging",
        "specversion": "1.0",
        "type": "Payload",
        "time": "2025-03-14T18:40:56.3356898+00:00",
        "data": "{\"Id\":\"8b939477-089c-49ce-ae90-49e9817bd593\",\"Name\":\"Test\",\"SomeValue\":42}"
    }

After

{
    "version": "0",
    "id": "ce7c8a25-da87-879d-100c-874adbaf9c51",
    "detail-type": "Payload",
    "source": "/aws/messaging",
    "account": "147997163238",
    "time": "2025-03-14T19:03:10Z",
    "region": "us-east-1",
    "resources": [],
    "detail": {
        "id": "0ef8cf5e-938a-4dc8-9b62-c6ccb3344bc7",
        "source": "/aws/messaging",
        "specversion": "1.0",
        "type": "Payload",
        "time": "2025-03-14T19:03:08.4022404+00:00",
        "datacontenttype": "application/json",
        "data": {
            "Id": "0172a7de-3757-4740-a771-4aca5f05d67c",
            "Name": "Test",
            "SomeValue": 42
        }
    }
}

Testing

  1. I followed the steps in Not properly formatting the data element of the MessageEnvelope #168 (comment) to validate the before and after

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

// EventBridge adds an external envelope which we need to strip away
var eventBridgeEnvelope = JsonSerializer.Deserialize<EventBridgeEnvelope>(message.Body);
Assert.NotNull(eventBridgeEnvelope);
var envelopeSerializer = _serviceProvider.GetRequiredService<IEnvelopeSerializer>();
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

these had to be updated because the previously used JsonSerializer.Deseerialize which doesnt work anymore with new format

@GarrettBeatty
Copy link
Contributor Author

closing this and will reopen on v4 development branch

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant