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

Not properly formatting the data element of the MessageEnvelope #168

Open
1 task
Scott-transtar opened this issue Dec 18, 2024 · 3 comments
Open
1 task
Assignees
Labels
bug Something isn't working needs-review p2 This is a standard priority issue

Comments

@Scott-transtar
Copy link

Describe the bug

According to the Cloud Event spect, https://github.com/cloudevents/spec/blob/v1.0.2/cloudevents/formats/json-format.md#3-envelope

If the datacontenttype is unspecified (and from what I have seen is not) then SHOULD proceed as if datacontenttype had been specified explicity as application/json. "The data value MUST be stored directly as a JSON value, rather than as an encoded JSON document represented as a string."

Currently, that is how data is being stored. Working on either end of the messages, this isn't a problem, however when publishing to an EventBus you cannot reference these values in Event pattern matching.

Regression Issue

  • Select this option if this issue appears to be a regression.

Expected Behavior

A setting is provided to specify the datacontenttype and is respected according to the spec.

If no datacontenttype is specified, as stated in the spec, it should be stored as a JSON value and not an encoded JSON document as a string.

Current Behavior

data is stored as an encoded JSON document represented as a string.

Reproduction Steps

Define a POCO for an EventBridge payload, use the AWS.Messaging library to publish the event. Have an Event Rule defined that will log to a Log Watch group and view the full json of the event, specifically in the detail section.

Possible Solution

No response

Additional Information/Context

No response

AWS.Messaging (or related) package versions

AWS.Messaging-0.9.2

Targeted .NET Platform

.NET 8

Operating System and version

Windows 11, any.

@Scott-transtar Scott-transtar added bug Something isn't working needs-triage This issue or PR still needs to be triaged. labels Dec 18, 2024
@bhoradc bhoradc added p2 This is a standard priority issue and removed needs-triage This issue or PR still needs to be triaged. labels Dec 18, 2024
@bhoradc
Copy link

bhoradc commented Dec 18, 2024

Hi @Scott-transtar,

Thank you for reporting the issue. Can you please share a minimal reproducible code solution for this issue?

Regards,
Chaitanya

@bhoradc bhoradc added the response-requested Waiting on additional info and feedback. Will move to "closing-soon" in 7 days. label Dec 18, 2024
@Scott-transtar
Copy link
Author

Scott-transtar commented Dec 18, 2024

Sure, here is a repo that can reproduce the issue. You will need to supply the ARN of your EventBridge in the Program.cs file.

https://github.com/Scott-transtar/AWS.Messaging.SerializatinIssue

Just look at the output in the log group.

Detail looks like:

"detail": {
"id": "84770dcb-350b-4013-bbaf-5c58c38a9c54",
"source": "/aws/messaging",
"specversion": "1.0",
"type": "Payload",
"time": "2024-12-18T21:59:49.5439189+00:00",
"data": "{\"Id\":\"513f3f46-7b30-4f15-8c31-3abc056b1715\",\"Name\":\"Test\",\"SomeValue\":42}"
}

And I would expect it to be:
`"detail": {
    "id": "84770dcb-350b-4013-bbaf-5c58c38a9c54",
    "source": "/aws/messaging",
    "specversion": "1.0",
    "type": "Payload",
    "time": "2024-12-18T21:59:49.5439189+00:00",
    "data": {
		"Id": "513f3f46-7b30-4f15-8c31-3abc056b1715",
		"Name": "Test",
		"SomeValue": 42
	}
}`

@github-actions github-actions bot removed the response-requested Waiting on additional info and feedback. Will move to "closing-soon" in 7 days. label Dec 19, 2024
@bhoradc bhoradc added the needs-reproduction This issue needs reproduction. label Dec 19, 2024
@bhoradc
Copy link

bhoradc commented Dec 27, 2024

Hello @Scott-transtar,

I appreciate you providing the self-contained code sample, which allows me to replicate the issue quickly.

To reproduce the problem, I followed below steps:

  1. Create an Event Bus from AWS console.
  2. For the above Event Bus, create a Rule.
  3. Set the Rule type to Rule with an event pattern.
  4. In the EventBridge pattern, select below pattern to match ANY source
 {
  "source": [{
    "prefix": ""
  }]
}
  1. For the Target types, choose AWS service (CloudWatch log group)."
  2. Execute the AWS.Messaging.SerializationIssue program.
  3. Check the Cloudwatch Log Event, which contains the following:
"detail": {
        "id": "070289aa-332e-4e69-a69b-429c1e39650f",
        "source": "/AmazonEC2/i-***",
        "specversion": "1.0",
        "type": "Payload",
        "time": "2024-12-27T16:08:24.7524137+00:00",
        "data": "{\"Id\":\"052dbeff-2648-4d1f-9efa-b7737c2fd851\",\"Name\":\"Test\",\"SomeValue\":42}"
    }

As you mentioned, the data field is represented as a string containing escaped JSON.

I will further investigate this issue with the team and provide an update.

Regards,
Chaitaya

@bhoradc bhoradc added needs-review and removed needs-reproduction This issue needs reproduction. labels Dec 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working needs-review p2 This is a standard priority issue
Projects
None yet
Development

No branches or pull requests

2 participants