Azure / azure-stream-analytics

Azure Stream Analytics
MIT License
224 stars 933 forks source link

JSON deserialization: Property already exists #35

Closed martijns closed 2 years ago

martijns commented 6 years ago

Stream analytics is unable to handle JSON messages where a property of an object is defined multiple times.

The following JSON message is submitted by a device to IoT Hub:

{
    "Property1": "value",
    "property1": "value",
    "property2": "value"
}

Stream analytics (listening on a consumer group of IoT Hub) does not process the message. Enabling execution logs shows the following error (with some id's redacted):

{
     "Environment": "Prod",
     "Region": "West Europe",
     "time": "2017-10-02T09:15:25.7096117Z",
     "resourceId": "/SUBSCRIPTIONS/<subscriptionid>/RESOURCEGROUPS/<resourcegroup>/PROVIDERS/MICROSOFT.STREAMANALYTICS/STREAMINGJOBS/<jobname>",
     "operationName": "Deserialize Events",
     "category": "Execution",
     "status": "Failed",
     "level": "Informational",
     "properties": "{\"Error\":\"\",\"Message\":\"Property with name 'property1' already exists. This message has occurred 21 times in past 10 minutes\",\"Type\":\"SerializerError\",\"Correlation ID\":\"982aa2c8-01ad-4ffa-a737-3df5a8b0a272\"}"
}

Newtonsoft's JSON deserializer does properly deserialize the object as tested with an Azure Function listening on another consumer group on the IoT Hub.

Even though JSON keys are recommended to be unique, they are not required to be so.

I guess it's up to the implementor to decide whether to error on this, but IMHO Stream Analytics should be robust and not error on a message like this.

HowardHoffman commented 6 years ago

I am seeing this issue even though the scope for the JSON keys should be differentiating.

For example:

{
   "propertyA" : "valueA",
   "propertyB" : "valueB",
   ...
   "level2" : {
      "eventStuff" : {
            "eventStuffProperty1" : "value1",
            "eventStuffProperty2" : "value2",
             ...
       }
      ...
   },
  "eventStuff" : {
        "eventStuffProperty1" : "value1",
        "eventStuffProperty2" : "value2",
          ...
   }
}

We sometimes get a Deserialization Error on "eventStuffProperty1".

Fleid commented 2 years ago

Closing stale issues