Skip to content
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

CSharp String Array Property setter fails #3813

Closed
rschiefer opened this issue Aug 27, 2019 · 6 comments · Fixed by aws/jsii#772
Closed

CSharp String Array Property setter fails #3813

rschiefer opened this issue Aug 27, 2019 · 6 comments · Fixed by aws/jsii#772
Assignees
Labels
@aws-cdk/aws-glue Related to AWS Glue bug This issue is a bug. language/dotnet Related to .NET bindings

Comments

@rschiefer
Copy link

rschiefer commented Aug 27, 2019

🐛 Bug Report

What is the problem?

Setting the Connections property on the ConnectionsListProperty in the Glue module with a valid string array fails to synthesize with the following error:

System.ArgumentException: Could not convert value 'System.Collections.Generic.Dictionary`2[System.String,System.Object]' with unrecognized type

Reproduction Steps

            var job = new Amazon.CDK.AWS.Glue.CfnJob(this, "testJob",  
                new CfnJobProps {
                    Name = "test",
                    GlueVersion = "1.0",
                    Role = "TestingGlueRole",
                    MaxCapacity = 4,
                    Connections = new ConnectionsListProperty
                    {
                        Connections = new string[1] { "AcmeData-test1" }
                    }
            });

Verbose Log

> 
> 1>Unhandled Exception: Amazon.JSII.Runtime.JsiiException: Amazon.JSII.Runtime.JsiiException: Resolution error: System.ArgumentException: Could not convert value 'System.Collections.Generic.Dictionary`2[System.String,System.Object]' with unrecognized type
> 1>Parameter name: value
> 1>   at Amazon.JSII.Runtime.Services.Converters.ValueConverter.ConvertAny(IReferenceMap referenceMap, Object value)
> 1>   at Amazon.JSII.Runtime.Services.Converters.ValueConverter.TryConvertPrimitive(IReferenceMap referenceMap, Object value, Boolean isOptional, PrimitiveType primitiveType, Object& result)
> 1>   at Amazon.JSII.Runtime.Services.Converters.ValueConverter.TryConvert(IOptionalValue optionalValue, IReferenceMap referenceMap, Object value, Object& result)
> 1>   at Amazon.JSII.Runtime.Services.Converters.FrameworkToJsiiConverter.TryConvertMap(IReferenceMap referenceMap, TypeReference elementType, Object value, Object& result)
> 1>   at Amazon.JSII.Runtime.Services.Converters.ValueConverter.TryConvert(IOptionalValue optionalValue, IReferenceMap referenceMap, Object value, Object& result)
> 1>   at Amazon.JSII.Runtime.Deputy.DeputyBase.<>c__DisplayClass20_0.<ConvertArguments>b__0(Parameter parameter, Object frameworkArgument)
> 1>   at System.Linq.Enumerable.ZipIterator[TFirst,TSecond,TResult](IEnumerable`1 first, IEnumerable`1 second, Func`3 resultSelector)+MoveNext()
> 1>   at System.Collections.Generic.LargeArrayBuilder`1.AddRange(IEnumerable`1 items)
> 1>   at System.Collections.Generic.EnumerableHelpers.ToArray[T](IEnumerable`1 source)
> 1>   at System.Linq.Enumerable.ToArray[TSource](IEnumerable`1 source)
> 1>   at Amazon.JSII.Runtime.Deputy.DeputyBase.<InvokeMethodCore>g__GetResult|18_0[T](<>c__DisplayClass18_0`1& )
> 1>   at Amazon.JSII.Runtime.Deputy.DeputyBase.InvokeMethodCore[T](JsiiMethodAttribute methodAttribute, Object[] arguments, Func`3 beginFunc, Func`3 invokeFunc)
> 1>   at Amazon.JSII.Runtime.Deputy.DeputyBase.InvokeInstanceMethod[T](Object[] arguments, String methodName).
> 1>Object creation stack:
> 1>  at new Intrinsic (C:\Users\user1\AppData\Local\Temp\jsii-kernel-WyVR6s\node_modules\@aws-cdk\core\lib\private\intrinsic.js:20:44)
> 1>  at new PostResolveToken (C:\Users\user1\AppData\Local\Temp\jsii-kernel-WyVR6s\node_modules\@aws-cdk\core\lib\util.js:72:9)
> 1>  at CfnJob._toCloudFormation (C:\Users\user1\AppData\Local\Temp\jsii-kernel-WyVR6s\node_modules\@aws-cdk\core\lib\cfn-resource.js:167:39)
> 1>  at node.addReference.resolve_1.findTokens (C:\Users\user1\AppData\Local\Temp\jsii-kernel-WyVR6s\node_modules\@aws-cdk\core\lib\cfn-element.js:84:77)
> 1>  at Object.findTokens (C:\Users\user1\AppData\Local\Temp\jsii-kernel-WyVR6s\node_modules\@aws-cdk\core\lib\private\resolve.js:126:13)
> 1>  at CfnJob.prepare (C:\Users\user1\AppData\Local\Temp\jsii-kernel-WyVR6s\node_modules\@aws-cdk\core\lib\cfn-element.js:84:49)
> 1>  at _wrapSandboxCode (C:\Users\user1\AppData\Local\Temp\l1havt1r.uvu\jsii-runtime.js:6498:51)
> 1>  at Kernel._wrapSandboxCode (C:\Users\user1\AppData\Local\Temp\l1havt1r.uvu\jsii-runtime.js:7131:20)
> 1>  at ret._ensureSync (C:\Users\user1\AppData\Local\Temp\l1havt1r.uvu\jsii-runtime.js:6498:25)
> 1>  at Kernel._ensureSync (C:\Users\user1\AppData\Local\Temp\l1havt1r.uvu\jsii-runtime.js:7102:20)
> 1>  at Kernel.invoke (C:\Users\user1\AppData\Local\Temp\l1havt1r.uvu\jsii-runtime.js:6497:26)
> 1>  at KernelHost.processRequest (C:\Users\user1\AppData\Local\Temp\l1havt1r.uvu\jsii-runtime.js:6191:28)
> 1>  at completeCallback (C:\Users\user1\AppData\Local\Temp\l1havt1r.uvu\jsii-runtime.js:6164:25)
> 1>  at KernelHost.callbackHandler (C:\Users\user1\AppData\Local\Temp\l1havt1r.uvu\jsii-runtime.js:6145:16)
> 1>  at KernelHost.kernel.jsii_kernel_1.Kernel.cb [as callbackHandler] (C:\Users\user1\AppData\Local\Temp\l1havt1r.uvu\jsii-runtime.js:6129:59)
> 1>  at CfnJob.value (C:\Users\user1\AppData\Local\Temp\l1havt1r.uvu\jsii-runtime.js:6848:41)
> 1>  at Function.prepare (C:\Users\user1\AppData\Local\Temp\jsii-kernel-WyVR6s\node_modules\@aws-cdk\core\lib\construct.js:89:27)
> 1>  at Function.synth (C:\Users\user1\AppData\Local\Temp\jsii-kernel-WyVR6s\node_modules\@aws-cdk\core\lib\construct.js:52:14)
> 1>  at App.synth (C:\Users\user1\AppData\Local\Temp\jsii-kernel-WyVR6s\node_modules\@aws-cdk\core\lib\app.js:67:52)
> 1>  at _wrapSandboxCode (C:\Users\user1\AppData\Local\Temp\l1havt1r.uvu\jsii-runtime.js:6498:51)
> 1>  at Kernel._wrapSandboxCode (C:\Users\user1\AppData\Local\Temp\l1havt1r.uvu\jsii-runtime.js:7131:20)
> 1>  at ret._ensureSync (C:\Users\user1\AppData\Local\Temp\l1havt1r.uvu\jsii-runtime.js:6498:25)
> 1>  at Kernel._ensureSync (C:\Users\user1\AppData\Local\Temp\l1havt1r.uvu\jsii-runtime.js:7102:20)
> 1>  at Kernel.invoke (C:\Users\user1\AppData\Local\Temp\l1havt1r.uvu\jsii-runtime.js:6497:26)
> 1>  at KernelHost.processRequest (C:\Users\user1\AppData\Local\Temp\l1havt1r.uvu\jsii-runtime.js:6191:28)
> 1>  at KernelHost.run (C:\Users\user1\AppData\Local\Temp\l1havt1r.uvu\jsii-runtime.js:6137:14)
> 1>  at processRequest (C:\Users\user1\AppData\Local\Temp\l1havt1r.uvu\jsii-runtime.js:6137:45)
> 1>  at KernelHost.processRequest (C:\Users\user1\AppData\Local\Temp\l1havt1r.uvu\jsii-runtime.js:6233:16)
> 1>  at KernelHost.run (C:\Users\user1\AppData\Local\Temp\l1havt1r.uvu\jsii-runtime.js:6137:14)
> 1>  at processRequest (C:\Users\user1\AppData\Local\Temp\l1havt1r.uvu\jsii-runtime.js:6137:45)
> 1>  at KernelHost.processRequest (C:\Users\user1\AppData\Local\Temp\l1havt1r.uvu\jsii-runtime.js:6233:16)
> 1>  at KernelHost.run (C:\Users\user1\AppData\Local\Temp\l1havt1r.uvu\jsii-runtime.js:6137:14)
> 1>  at processRequest (C:\Users\user1\AppData\Local\Temp\l1havt1r.uvu\jsii-runtime.js:6137:45)
> 1>  at promise.then.val (C:\Users\user1\AppData\Local\Temp\l1havt1r.uvu\jsii-runtime.js:6218:21)
> 1>   at Amazon.JSII.Runtime.Services.Client.TryDeserialize[TResponse](String responseJson)
> 1>   at Amazon.JSII.Runtime.Services.Client.ReceiveResponse[TResponse]()
> 1>   at Amazon.JSII.Runtime.Services.Client.TryDeserialize[TResponse](String responseJson)
> 1>   at Amazon.JSII.Runtime.Services.Client.ReceiveResponse[TResponse]()
> 1>   at Amazon.JSII.Runtime.Deputy.DeputyBase.<InvokeMethodCore>g__GetResult|18_0[T](<>c__DisplayClass18_0`1& )
> 1>   at Amazon.JSII.Runtime.Deputy.DeputyBase.InvokeMethodCore[T](JsiiMethodAttribute methodAttribute, Object[] arguments, Func`3 beginFunc, Func`3 invokeFunc)
> 1>   at Amazon.JSII.Runtime.Deputy.DeputyBase.InvokeInstanceMethod[T](Object[] arguments, String methodName)
> 1>   at Amazon.CDK.CfnElement.Prepare()
> 1>   at Amazon.JSII.Runtime.Services.Client.TryDeserialize[TResponse](String responseJson)
> 1>   at Amazon.JSII.Runtime.Services.Client.ReceiveResponse[TResponse]()
> 1>   at Amazon.JSII.Runtime.Services.Client.TryDeserialize[TResponse](String responseJson)
> 1>   at Amazon.JSII.Runtime.Services.Client.ReceiveResponse[TResponse]()
> 1>   at Amazon.JSII.Runtime.Deputy.DeputyBase.<InvokeMethodCore>g__GetResult|18_0[T](<>c__DisplayClass18_0`1& )
> 1>   at Amazon.JSII.Runtime.Deputy.DeputyBase.InvokeMethodCore[T](JsiiMethodAttribute methodAttribute, Object[] arguments, Func`3 beginFunc, Func`3 invokeFunc)
> 1>   at Amazon.JSII.Runtime.Deputy.DeputyBase.InvokeInstanceMethod[T](Object[] arguments, String methodName)
> 1>   at Acme.Data.CloudFormation.Program.Stuff() in D:\source\acme-providerdata\Acme.Data.CloudFormation\Program.cs:line 24
> 1>   at Acme.Data.CloudFormation.Program.Main(String[] args) in D:\source\acme-providerdata\Acme.Data.CloudFormation\Program.cs:line 16
> 1>Subprocess exited with error 3762504530
> 1>D:\source\acme-providerdata\Acme.Data.CloudFormation\Acme.Data.CloudFormation.csproj(55,5): error MSB3073: The command "cdk synth -a "dotnet bin\Debug\netcoreapp2.1\Acme.Data.CloudFormation.dll"" exited with code 1.
> 

Environment

  • CDK CLI Version: 1.5.0 (build c020efa)
  • Module Version: Glue 1.5
  • OS: Windows 10
  • Language: CSharp

Other information

@rschiefer rschiefer added bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels Aug 27, 2019
@assyadh
Copy link
Contributor

assyadh commented Aug 27, 2019

Relates #2496

This will be fixed in the next release of the Amazon.JSII.Runtime nuget package

@NGL321 NGL321 added language/dotnet Related to .NET bindings @aws-cdk/aws-glue Related to AWS Glue and removed needs-triage This issue or PR still needs to be triaged. labels Aug 27, 2019
@rschiefer
Copy link
Author

rschiefer commented Aug 29, 2019

@assyadh Updated to latest release from yesterday and still failing with the same error:

image

@McDoit
Copy link
Contributor

McDoit commented Aug 29, 2019

@rschiefer Try to install the latest JSII Runtime
Install-Package Amazon.JSII.Runtime -Version 0.16.0 or the latest CDK, 1.6.1

@rschiefer
Copy link
Author

New error: Unhandled Exception: Amazon.JSII.Runtime.JsiiException: Amazon.JSII.Runtime.JsiiException: Resolution error: System.ArgumentException: Could not infer JSII type for .NET type 'JArray'

image

@McDoit
Copy link
Contributor

McDoit commented Aug 29, 2019

@rschiefer Welcome to the club of #3244 !

@monnecc
Copy link

monnecc commented Sep 9, 2019

I'm also experiencing the original issue with Amazon.CDK 1.7.0-devpreview (and Amazon.JSII.Runtime 0.16.0).

var role = new Role(this, "rolepatterns", new RoleProps { RoleName = "rolepatterns", AssumedBy = new Amazon.CDK.AWS.IAM.ServicePrincipal("lambda"), ManagedPolicies = new[] { ManagedPolicy.FromAwsManagedPolicyName("service-role/AWSLambdaSQSQueueExecutionRole") }, InlinePolicies = new Dictionary<string, PolicyDocument> { { "AllowSNSPublish", new PolicyDocument( new PolicyDocumentProps { Statements = new [] { new PolicyStatement( new PolicyStatementProps { Effect = Effect.ALLOW, Actions = new[] { "sns:Publish" }, Resources = new[] { "*" } }) } }) } } });

RomainMuller pushed a commit to aws/jsii that referenced this issue Sep 18, 2019
…telisense docs, set target to netcoreapp2.1 (#772)

This PR fixes various issues due to how we convert collection elements, and how the type reference is passed when converting.


These two issues are similar and are due to nested Arrays of object not being casted properly:
Fixes aws/aws-cdk#3244
Fixes aws/aws-cdk#3672
Added a unit test to cover the case

This issue is due to Maps of Arrays of Anys not being casted properly:
Fixes aws/aws-cdk#3813 
Added a unit test to cover the case

Also added support for xml documentation which is now added to the NuGet packages and should allow intellisense to provide in IDE help:
Fixes #749
Fixes aws/aws-cdk#1846

Migrated the target framework to netcoreapp2.1 instead of netstandard2.0:
Fixes #714
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
@aws-cdk/aws-glue Related to AWS Glue bug This issue is a bug. language/dotnet Related to .NET bindings
Projects
None yet
5 participants