Skip to content

[BUG] EventGridEvent.ParseMany Requires Camel Case #39961

Closed
@WTSParadigm

Description

@WTSParadigm

Library name and version

Azure.Messaging.EventGrid 4.21.0

Describe the bug

If the event json sent to event grid is not camel case, it still gets sent through event grid fine. But if you try to parse that event in a subscription you will get errors like "Subject is null".

e.g. sending this event json directly to an event grid domain works correctly:

[
    {
        "Data": {
            "EventData": {
                "QuoteNumber": "1234"
            },
        },
        "DataVersion": "1.0",
        "EventTime": "2023-11-13T20:59:06.1393157Z",
        "EventType": "EventType",
        "ID": "49a3720e-f01d-4f67-8214-60294a77794b",
        "MetadataVersion": "1",
        "Subject": "Test Event",
        "Topic": "<topicid>"
    }
]

But when it hits the subscription, in my case I have an azure function acting as a custom webhook, you get the error when trying to call ParseMany

 public async Task<HttpResponseData> HandleEventAsync(
     [HttpTrigger(AuthorizationLevel.Anonymous, "get", "post", Route = null)] HttpRequestData req,
     CancellationToken cancellationToken = default)
 {           
     string response = string.Empty;
     BinaryData events = await BinaryData.FromStreamAsync(req.Body);
     
     _logger.LogInformation($"Received events: {events}");

     EventGridEvent[] eventGridEvents = EventGridEvent.ParseMany(events);

Expected behavior

It should be able to parse the JSON regardless of case, or event grid should send the event to the subscription with camel casing regardless of how it was received

Actual behavior

The subscription fails to parse the events saying "The subject parameter is null"

Reproduction Steps

var data = BinaryData.FromString("[\r\n {\r\n "Data": {\r\n "EventData": {\r\n "QuoteNumber": "1234"\r\n }\r\n },\r\n "DataVersion": "1.0",\r\n "EventTime": "2023-11-13T20:59:06.1393157Z",\r\n "EventType": "EventType",\r\n "ID": "49a3720e-f01d-4f67-8214-60294a77794b",\r\n "MetadataVersion": "1",\r\n "Subject": "Test Event",\r\n "Topic": ""\r\n }\r\n]");
EventGridEvent[] eventGridEvents = EventGridEvent.ParseMany(data);

Environment

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    ClientThis issue is related to a non-management packageEvent Gridcustomer-reportedIssues that are reported by GitHub users external to the Azure organization.needs-author-feedbackWorkflow: More information is needed from author to address the issue.needs-team-attentionWorkflow: This issue needs attention from Azure service team or SDK teamquestionThe issue doesn't require a change to the product in order to be resolved. Most issues start as that

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions