-
Notifications
You must be signed in to change notification settings - Fork 6
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
The CloudEvent source gets overwritten by the emulator #106
Comments
Hi, I stumbled into the same problem as the topic poster today. The CloudEvent I'm posting towards the EventGrid topic follows this format: {
"id": "5e3ab450-f4a5-40cc-b1ec-819b0bd1bc26",
👉 "source": "/my-source-identifier",
"data": {
"..."
},
"type": "my.type.of.event",
"time": "2025-01-17T14:07:03.303787590Z",
"specversion": "1.0",
"datacontenttype": "application/json"
} On the subscription endpoint, I suddenly see this event: {
"id": "5e3ab450-f4a5-40cc-b1ec-819b0bd1bc26",
👉 "source": "/subscriptions/00000000-0000-0000-0000-00000000/resourceGroups/my-resource-group/providers/Microsoft.EventGrid/topics/my-event-grid-topic",
"data": {
"..."
},
"type": "my.type.of.event",
"time": "2025-01-17T14:07:03.303787590Z",
"specversion": "1.0",
"datacontenttype": "application/json"
} On the subscription endpoint, we actually rely on the value in the diff --git a/src/EventGridEmulator/EventHandling/CloudEventHttpContextHandler.cs b/src/EventGridEmulator/EventHandling/CloudEventHttpContextHandler.cs
index 44bef91..22ef190 100644
--- a/src/EventGridEmulator/EventHandling/CloudEventHttpContextHandler.cs
+++ b/src/EventGridEmulator/EventHandling/CloudEventHttpContextHandler.cs
@@ -21,7 +21,10 @@ internal sealed class CloudEventHttpContextHandler : BaseEventHttpContextHandler
{
foreach (var @event in cloudEvents)
{
- @event.Source = $"{SubscriberConstants.DefaultTopicValue}{topicName}";
+ if (String.IsNullOrEmpty(@event.Source))
+ {
+ @event.Source = $"{SubscriberConstants.DefaultTopicValue}{topicName}";
+ }
}
} |
If the emulator behavior differ from EventGrid, then it should be fixed. Would you like to create a PR with the suggested fix? |
Thanks for your reply @meziantou! According to the contributing guidelines on this repository, I noticed you don't accept external pull requests (yet). But I assume you allow a PR from a forked repository? |
You can create a PR from your fork. To accept the PR, and because of our compliance process, we'll create a new PR with your commits (you will still be author of the commit in the git history). |
Hey that's great! I already have a fork, I'll get to it soon. Thanks both for the updates! |
Opened #107 as a fix |
Happy to announce that with version |
Describe the bug
The original source of the CloudEvent gets overwritten by the topic.
To Reproduce
Steps to reproduce the behavior:
Expected behavior
The source should stay the same as received originally.
Additional context
Permalink to where this issue happens
As described above. In azure the original source from the cloud event is kept when forwarding it to the subscribed endpoints.
The text was updated successfully, but these errors were encountered: