Closed
Description
openedon Feb 21, 2019
Bug Report
-
import path of package in question:
github.com/Azure/azure-sdk-for-go/services/preview/monitor/mgmt/2018-09-01/insights
but also the2018-03-01
and2018-11-01
are the same. -
SDK version e.g.
master
,latest
,18.1.0
v24, but v25 seems to have the same issue. -
output of
go version
go version go1.11.5 darwin/amd64
- What happened?
The SDK sends the wrong payload. from the request:
"action": {
"criteria": {
"metricName": "metric",
"dimensions": []
},
"odata.type": "Microsoft.WindowsAzure.Management.Monitoring.Alerts.Models.Microsoft.AppInsights.Nexus.DataContracts.Resources.ScheduledQueryRules.LogToMetricAction"
}
what the documentation indicates it should be:
"action": {
"criteria": [
{
"metricName": "Average_% Idle Time",
"dimensions": []
}
],
"odata.type": "Microsoft.WindowsAzure.Management.Monitoring.Alerts.Models.Microsoft.AppInsights.Nexus.DataContracts.Resources.ScheduledQueryRules.LogToMetricAction"
}
action.criteria should be an array. The response we get back seems to confirm this:
=== RUN TestAccAzureRMMonitorScheduledQueryRule_basicActionLog
=== PAUSE TestAccAzureRMMonitorScheduledQueryRule_basicActionLog
=== CONT TestAccAzureRMMonitorScheduledQueryRule_basicActionLog
--- FAIL: TestAccAzureRMMonitorScheduledQueryRule_basicActionLog (139.28s)
testing.go:538: Step 0 error: Error applying: 1 error occurred:
* azurerm_monitor_scheduled_query_rule.test: 1 error occurred:
* azurerm_monitor_scheduled_query_rule.test: Error creating or updating Monitor Scheduled Query Rule "acctestqr[1]d" (resource group "acctestRG-190220214523581544"): insights.ScheduledQueryRulesClient#CreateOrUpdate: Failure responding to request: StatusCode=400 -- Original Error: autorest/azure: error response cannot be parsed: "{\r\n \"error\": {\r\n \"code\": \"Failed to deserialize payload : Cannot deserialize the current JSON object (e.g. {\\\"name\\\":\\\"value\\\"}) into type 'System.Collections.Generic.List`1[Microsoft.AppInsights.Nexus.DataContracts.Resources.ScheduledQueryRules.Criteria]' because the type requires a JSON array (e.g. [1,2,3]) to deserialize correctly.\",\r\n \"message\": {\r\n \"lang\": \"en-US\",\r\n \"value\": \"Failed to deserialize payload : Cannot deserialize the current JSON object (e.g. {\\\"name\\\":\\\"value\\\"}) into type 'System.Collections.Generic.List`1[Microsoft.AppInsights.Nexus.DataContracts.Resources.ScheduledQueryRules.Criteria]' because the type requires a JSON array (e.g. [1,2,3]) to deserialize correctly.\\r\\nTo fix this error either change the JSON to a JSON array (e.g. [1,2,3]) or change the deserialized type so that it is a normal .NET type (e.g. not a primitive type like integer, not a collection type like an array or List<T>) that can be deserialized from a JSON object. JsonObjectAttribute can also be added to the type to force it to deserialize from a JSON object.\\r\\nPath 'criteria.metricName'.\"\r\n },\r\n \"innererror\": {\r\n \"stacktrace\": \"System.ArgumentException: Failed to deserialize payload : Cannot deserialize the current JSON object (e.g. {\\\"name\\\":\\\"value\\\"}) into type 'System.Collections.Generic.List`1[Microsoft.AppInsights.Nexus.DataContracts.Resources.ScheduledQueryRules.Criteria]' because the type requires a JSON array (e.g. [1,2,3]) to deserialize correctly.\\r\\nTo fix this error either change the JSON to a JSON array (e.g. [1,2,3]) or change the deserialized type so that it is a normal .NET type (e.g. not a primitive type like integer, not a collection type like an array or List<T>) that can be deserialized from a JSON object. JsonObjectAttribute can also be added to the type to force it to deserialize from a JSON object.\\r\\nPath 'criteria.metricName'. ---> Newtonsoft.Json.JsonSerializationException: Cannot deserialize the current JSON object (e.g. {\\\"name\\\":\\\"value\\\"}) into type 'System.Collections.Generic.List`1[Microsoft.AppInsights.Nexus.DataContracts.Resources.ScheduledQueryRules.Criteria]' because the type requires a JSON array (e.g. [1,2,3]) to deserialize correctly.\\r\\nTo fix this error either change the JSON to a JSON array (e.g. [1,2,3]) or change the deserialized type so that it is a normal .NET type (e.g. not a primitive type like integer, not a collection type like an array or List<T>) that can be deserialized from a JSON object. JsonObjectAttribute can also be added to the type to force it to deserialize from a JSON object.\\r\\nPath 'criteria.metricName'.\\r\\n at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateObject(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMember, Object existingValue)\\r\\n at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.SetPropertyValue(JsonProperty property, JsonConverter propertyConverter, JsonContainerContract containerContract, JsonProperty containerProperty, JsonReader reader, Object target)\\r\\n at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.PopulateObject(Object newObject, JsonReader reader, JsonObjectContract contract, JsonProperty member, String id)\\r\\n at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateObject(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMember, Object existingValue)\\r\\n at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.Deserialize(JsonReader reader, Type objectType, Boolean checkAdditionalContent)\\r\\n at Newtonsoft.Json.Linq.JToken.ToObject(Type objectType, JsonSerializer jsonSerializer)\\r\\n at Newtonsoft.Json.Linq.JToken.ToObject[T](JsonSerializer jsonSerializer)\\r\\n at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.DeserializeConvertable(JsonConverter converter, JsonReader reader, Type objectType, Object existingValue)\\r\\n at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.SetPropertyValue(JsonProperty property, JsonConverter propertyConverter, JsonContainerContract containerContract, JsonProperty containerProperty, JsonReader reader, Object target)\\r\\n at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.PopulateObject(Object newObject, JsonReader reader, JsonObjectContract contract, JsonProperty member, String id)\\r\\n at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateObject(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMember, Object existingValue)\\r\\n at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.SetPropertyValue(JsonProperty property, JsonConverter propertyConverter, JsonContainerContract containerContract, JsonProperty containerProperty, JsonReader reader, Object target)\\r\\n at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.PopulateObject(Object newObject, JsonReader reader, JsonObjectContract contract, JsonProperty member, String id)\\r\\n at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateObject(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMember, Object existingValue)\\r\\n at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.Deserialize(JsonReader reader, Type objectType, Boolean checkAdditionalContent)\\r\\n at Newtonsoft.Json.JsonSerializer.DeserializeInternal(JsonReader reader, Type objectType)\\r\\n at Newtonsoft.Json.Linq.JToken.ToObject(Type objectType, JsonSerializer jsonSerializer)\\r\\n at Newtonsoft.Json.Linq.JToken.ToObject[T](JsonSerializer jsonSerializer)\\r\\n at Microsoft.AppInsights.Nexus.ResourceProvider.Csm.CsmResourceProvider`1.PutResourceAsync[T](String subscriptionId, String resourceGroupName, String resourceName, JObject resourceEnv, String eTag, RpRequestOptions options, String operationId) in X:\\\\bt\\\\988380\\\\repo\\\\src\\\\SQR-CDS\\\\Nexus\\\\ResourceProvider\\\\Csm\\\\CsmResourceProvider.cs:line 226\\r\\n --- End of inner exception stack trace ---\\r\\n at Microsoft.AppInsights.Nexus.ResourceProvider.Csm.CsmResourceProvider`1.PutResourceAsync[T](String subscriptionId, String resourceGroupName, String resourceName, JObject resourceEnv, String eTag, RpRequestOptions options, String operationId) in X:\\\\bt\\\\988380\\\\repo\\\\src\\\\SQR-CDS\\\\Nexus\\\\ResourceProvider\\\\Csm\\\\CsmResourceProvider.cs:line 230\\r\\n at Microsoft.ManagementServices.Rules.Endpoint.Controllers.Nexus.CsmResourcesNxControllerBase`1.<>c__DisplayClass13_0.<<PutResourceAsync>b__0>d.MoveNext() in X:\\\\bt\\\\988380\\\\repo\\\\src\\\\SQR-CDS\\\\Service\\\\Endpoint\\\\Controllers\\\\Nexus\\\\CsmResourcesNxControllerBase.cs:line 208\\r\\n--- End of stack trace from previous location where exception was thrown ---\\r\\n at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\\r\\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\\r\\n at Microsoft.ManagementServices.Rules.Endpoint.Controllers.Nexus.NexusControllerBase.<PerformActionAsync>d__17.MoveNext() in X:\\\\bt\\\\988380\\\\repo\\\\src\\\\SQR-CDS\\\\Service\\\\Endpoint\\\\Controllers\\\\Nexus\\\\NexusControllerBase.cs:line 97\"\r\n }\r\n }\r\n}" error: json: cannot unmarshal object into Go struct field serviceError2.message of type string
with some formatting:
{
"error": {
"code": "Failed to deserialize payload : Cannot deserialize the current JSON object (e.g. {\"name\":\"value\"}) into type 'System.Collections.Generic.List`1[Microsoft.AppInsights.Nexus.DataContracts.Resources.ScheduledQueryRules.Criteria]' because the type requires a JSON array (e.g. [1,2,3]) to deserialize correctly.",
"message": {
"lang": "en-US",
"value": "Failed to deserialize payload : Cannot deserialize the current JSON object (e.g. {\"name\":\"value\"}) into type 'System.Collections.Generic.List`1[Microsoft.AppInsights.Nexus.DataContracts.Resources.ScheduledQueryRules.Criteria]' because the type requires a JSON array (e.g. [1,2,3]) to deserialize correctly.\r\nTo fix this error either change the JSON to a JSON array (e.g. [1,2,3]) or change the deserialized type so that it is a normal .NET type (e.g. not a primitive type like integer, not a collection type like an array or List<T>) that can be deserialized from a JSON object. JsonObjectAttribute can also be added to the type to force it to deserialize from a JSON object.\r\nPath 'criteria.metricName'."
},
"innererror": {
"stacktrace": "System.ArgumentException: Failed to deserialize payload : Cannot deserialize the current JSON object (e.g. {\"name\":\"value\"}) into type 'System.Collections.Generic.List`1[Microsoft.AppInsights.Nexus.DataContracts.Resources.ScheduledQueryRules.Criteria]' because the type requires a JSON array (e.g. [1,2,3]) to deserialize correctly.\r\nTo fix this error either change the JSON to a JSON array (e.g. [1,2,3]) or change the deserialized type so that it is a normal .NET type (e.g. not a primitive type like integer, not a collection type like an array or List<T>) that can be deserialized from a JSON object. JsonObjectAttribute can also be added to the type to force it to deserialize from a JSON object.\r\nPath 'criteria.metricName'. ---> Newtonsoft.Json.JsonSerializationException: Cannot deserialize the current JSON object (e.g. {\"name\":\"value\"}) into type 'System.Collections.Generic.List`1[Microsoft.AppInsights.Nexus.DataContracts.Resources.ScheduledQueryRules.Criteria]' because the type requires a JSON array (e.g. [1,2,3]) to deserialize correctly.\r\nTo fix this error either change the JSON to a JSON array (e.g. [1,2,3]) or change the deserialized type so that it is a normal .NET type (e.g. not a primitive type like integer, not a collection type like an array or List<T>) that can be deserialized from a JSON object. JsonObjectAttribute can also be added to the type to force it to deserialize from a JSON object.\r\nPath 'criteria.metricName'.\r\n at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateObject(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMember, Object existingValue)\r\n at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.SetPropertyValue(JsonProperty property, JsonConverter propertyConverter, JsonContainerContract containerContract, JsonProperty containerProperty, JsonReader reader, Object target)\r\n at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.PopulateObject(Object newObject, JsonReader reader, JsonObjectContract contract, JsonProperty member, String id)\r\n at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateObject(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMember, Object existingValue)\r\n at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.Deserialize(JsonReader reader, Type objectType, Boolean checkAdditionalContent)\r\n at Newtonsoft.Json.Linq.JToken.ToObject(Type objectType, JsonSerializer jsonSerializer)\r\n at Newtonsoft.Json.Linq.JToken.ToObject[T](JsonSerializer jsonSerializer)\r\n at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.DeserializeConvertable(JsonConverter converter, JsonReader reader, Type objectType, Object existingValue)\r\n at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.SetPropertyValue(JsonProperty property, JsonConverter propertyConverter, JsonContainerContract containerContract, JsonProperty containerProperty, JsonReader reader, Object target)\r\n at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.PopulateObject(Object newObject, JsonReader reader, JsonObjectContract contract, JsonProperty member, String id)\r\n at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateObject(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMember, Object existingValue)\r\n at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.SetPropertyValue(JsonProperty property, JsonConverter propertyConverter, JsonContainerContract containerContract, JsonProperty containerProperty, JsonReader reader, Object target)\r\n at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.PopulateObject(Object newObject, JsonReader reader, JsonObjectContract contract, JsonProperty member, String id)\r\n at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateObject(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMember, Object existingValue)\r\n at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.Deserialize(JsonReader reader, Type objectType, Boolean checkAdditionalContent)\r\n at Newtonsoft.Json.JsonSerializer.DeserializeInternal(JsonReader reader, Type objectType)\r\n at Newtonsoft.Json.Linq.JToken.ToObject(Type objectType, JsonSerializer jsonSerializer)\r\n at Newtonsoft.Json.Linq.JToken.ToObject[T](JsonSerializer jsonSerializer)\r\n at Microsoft.AppInsights.Nexus.ResourceProvider.Csm.CsmResourceProvider`1.PutResourceAsync[T](String subscriptionId, String resourceGroupName, String resourceName, JObject resourceEnv, String eTag, RpRequestOptions options, String operationId) in X:\\bt\\988380\\repo\\src\\SQR-CDS\\Nexus\\ResourceProvider\\Csm\\CsmResourceProvider.cs:line 226\r\n --- End of inner exception stack trace ---\r\n at Microsoft.AppInsights.Nexus.ResourceProvider.Csm.CsmResourceProvider`1.PutResourceAsync[T](String subscriptionId, String resourceGroupName, String resourceName, JObject resourceEnv, String eTag, RpRequestOptions options, String operationId) in X:\\bt\\988380\\repo\\src\\SQR-CDS\\Nexus\\ResourceProvider\\Csm\\CsmResourceProvider.cs:line 230\r\n at Microsoft.ManagementServices.Rules.Endpoint.Controllers.Nexus.CsmResourcesNxControllerBase`1.<>c__DisplayClass13_0.<<PutResourceAsync>b__0>d.MoveNext() in X:\\bt\\988380\\repo\\src\\SQR-CDS\\Service\\Endpoint\\Controllers\\Nexus\\CsmResourcesNxControllerBase.cs:line 208\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at Microsoft.ManagementServices.Rules.Endpoint.Controllers.Nexus.NexusControllerBase.<PerformActionAsync>d__17.MoveNext() in X:\\bt\\988380\\repo\\src\\SQR-CDS\\Service\\Endpoint\\Controllers\\Nexus\\NexusControllerBase.cs:line 97"
}
}
}
May also want to investigate a full stack trace being returned.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment