You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Unhandled exception. Newtonsoft.Json.JsonSerializationException: Error converting value "Error" to type 'Amazon.JSII.JsonModel.Api.Response.ErrorResponseName'. Path 'name'. ---> System.ArgumentException: Requested value 'Error' was not found. at Newtonsoft.Json.Utilities.EnumUtils.ParseEnum(Type enumType, NamingStrategy namingStrategy, String value, Boolean disallowNumber) at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.EnsureType(JsonReader reader, Object value, CultureInfo culture, JsonContract contract, Type targetType) --- End of inner exception stack trace --- at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.EnsureType(JsonReader reader, Object value, CultureInfo culture, JsonContract contract, Type targetType) at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateValueInternal(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMemb er, Object existingValue) at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.ResolvePropertyAndCreatorValues(JsonObjectContract contract, JsonProperty containerProperty, JsonReader reader, Type objectType) at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateObjectUsingCreatorWithParameters(JsonReader reader, JsonObjectContract contract, JsonProperty containerProperty, ObjectConstructor1 creator, String id)
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateObject(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMember, Obj
ect existingValue)
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateValueInternal(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMemb
er, Object existingValue)
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.Deserialize(JsonReader reader, Type objectType, Boolean checkAdditionalContent)
at Newtonsoft.Json.JsonSerializer.DeserializeInternal(JsonReader reader, Type objectType)
at Newtonsoft.Json.Linq.JToken.ToObject(Type objectType, JsonSerializer jsonSerializer)
at Newtonsoft.Json.Linq.JToken.ToObject(Type objectType)
at Newtonsoft.Json.Linq.JToken.ToObjectT
at Amazon.JSII.Runtime.Services.Client.TryDeserialize[TResponse](String responseJson)
at Amazon.JSII.Runtime.Services.Client.ReceiveResponseTResponse
at Amazon.JSII.Runtime.Services.Client.Send[TRequest,TResponse](TRequest requestObject)
at Amazon.JSII.Runtime.Services.Client.Create(CreateRequest request)
at Amazon.JSII.Runtime.Services.Client.Create(String fullyQualifiedName, Object[] arguments, Override[] overrides, String[] interfaces)
at Amazon.JSII.Runtime.Deputy.DeputyBase..ctor(DeputyProps props)
at Amazon.CDK.AWS.CloudWatch.MathExpression..ctor(IMathExpressionProps props)
`
Reproduction Steps
Queue[] queues;
var props = new MathExpressionProps {
Expression = "SUM(METRICS())",
UsingMetrics = new Dictionary<string, IMetric>
{
{"1", queues[0].MetricApproximateNumberOfMessagesVisible()},
{"2", queues[1].MetricApproximateNumberOfMessagesVisible()},
}
};
var combinedMetrics = new MathExpression(props);
Possible Solution
No response
Additional Information/Context
I changed to Version 2.50 and 2.41 with the same result.
CDK CLI Version
2.46.0
Framework Version
No response
Node.js Version
v18.12.0
OS
Windows 10/Linux (both)
Language
.NET
Language Version
dotnet 6
Other information
No response
The text was updated successfully, but these errors were encountered:
Thanks for reporting this issue, I was able to reproduce the same issue in .NET on the latest version of CDK. Here's my full stack code:
using Amazon.CDK;
using Constructs;
using Amazon.CDK.AWS.CloudWatch;
using Amazon.CDK.AWS.SQS;
namespace Dotnet
{
public class DotnetStack : Stack
{
internal DotnetStack(Construct scope, string id, IStackProps props = null) : base(scope, id, props)
{
var queue1 = new Queue(this, "Queue1");
var queue2 = new Queue(this, "Queue2");
var sprops = new MathExpressionProps {
Expression = "SUM(METRICS())",
UsingMetrics = new System.Collections.Generic.Dictionary<string, IMetric>
{
{"1", queue1.MetricApproximateNumberOfMessagesVisible()},
{"2", queue2.MetricApproximateNumberOfMessagesVisible()},
}
};
var combinedMetrics = new MathExpression(sprops);
}
}
}
I was not able to reproduce the same issue in TypeScript, which indicates to me that this is a JSII issue when translating between .NET and JavaScript. So, I'm going to move this issue to the JSII repo. Let's see what they say 🙂
I am able to reproduce this in CDK v2.46.0. The error message is very opaque. However in later versions (at least in CDK v2.78.0+) we produce a different error that is more illuminating:
Unhandled exception. System.Exception: Invalid variable names in expression: 1,2. Must start with lowercase letter and only contain alphanumerics.
The problem here is that you can't name your variables 1 and 2. They must start with a-z. I can confirm that after updating to get your variables in line with the requirements the code deploys successfully.
Hope this helps, and sorry about the opaque error message!
This issue is now closed. Comments on closed issues are hard for our team to see.
If you need more assistance, please open a new issue that references this one.
Describe the bug
I'm not able to create a MathExpression, instead 'cdk diff' throws an exception.
My code looks something like this:
I'm not able to find some problem in my code. I also used a different expression, but the result is the same (analog to Docu [1])
[1] https://docs.aws.amazon.com/cdk/api/v2/dotnet/api/Amazon.CDK.AWS.CloudWatch.MathExpression.html#Amazon_CDK_AWS_CloudWatch_MathExpression_Expression
Expected Behavior
No exception
Current Behavior
This is the exception I get
Unhandled exception. Newtonsoft.Json.JsonSerializationException: Error converting value "Error" to type 'Amazon.JSII.JsonModel.Api.Response.ErrorResponseName'. Path 'name'. ---> System.ArgumentException: Requested value 'Error' was not found. at Newtonsoft.Json.Utilities.EnumUtils.ParseEnum(Type enumType, NamingStrategy namingStrategy, String value, Boolean disallowNumber) at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.EnsureType(JsonReader reader, Object value, CultureInfo culture, JsonContract contract, Type targetType) --- End of inner exception stack trace --- at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.EnsureType(JsonReader reader, Object value, CultureInfo culture, JsonContract contract, Type targetType) at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateValueInternal(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMemb er, Object existingValue) at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.ResolvePropertyAndCreatorValues(JsonObjectContract contract, JsonProperty containerProperty, JsonReader reader, Type objectType) at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateObjectUsingCreatorWithParameters(JsonReader reader, JsonObjectContract contract, JsonProperty containerProperty, ObjectConstructor
1 creator, String id)at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateObject(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMember, Obj
ect existingValue)
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateValueInternal(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMemb
er, Object existingValue)
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.Deserialize(JsonReader reader, Type objectType, Boolean checkAdditionalContent)
at Newtonsoft.Json.JsonSerializer.DeserializeInternal(JsonReader reader, Type objectType)
at Newtonsoft.Json.Linq.JToken.ToObject(Type objectType, JsonSerializer jsonSerializer)
at Newtonsoft.Json.Linq.JToken.ToObject(Type objectType)
at Newtonsoft.Json.Linq.JToken.ToObjectT
at Amazon.JSII.Runtime.Services.Client.TryDeserialize[TResponse](String responseJson)
at Amazon.JSII.Runtime.Services.Client.ReceiveResponseTResponse
at Amazon.JSII.Runtime.Services.Client.Send[TRequest,TResponse](TRequest requestObject)
at Amazon.JSII.Runtime.Services.Client.Create(CreateRequest request)
at Amazon.JSII.Runtime.Services.Client.Create(String fullyQualifiedName, Object[] arguments, Override[] overrides, String[] interfaces)
at Amazon.JSII.Runtime.Deputy.DeputyBase..ctor(DeputyProps props)
at Amazon.CDK.AWS.CloudWatch.MathExpression..ctor(IMathExpressionProps props)
`
Reproduction Steps
Possible Solution
No response
Additional Information/Context
I changed to Version 2.50 and 2.41 with the same result.
CDK CLI Version
2.46.0
Framework Version
No response
Node.js Version
v18.12.0
OS
Windows 10/Linux (both)
Language
.NET
Language Version
dotnet 6
Other information
No response
The text was updated successfully, but these errors were encountered: