question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

CSharp String Array Property setter fails

See original GitHub issue

🐛 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

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
assyadhcommented, Aug 27, 2019

Relates https://github.com/aws/aws-cdk/issues/2496

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

1reaction
rschiefercommented, Aug 29, 2019

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

Read more comments on GitHub >

github_iconTop Results From Across the Web

c# - getters setters array - Stack Overflow
This is never going to work: Array = "gdgd";. That's trying to assign a string value to a string[] property. Note that you...
Read more >
Help! How to write 'get''set' property for an array of structs?
To access this array from the main class which contains main(), i attempted to write 'get/set properties' for the array, but it seems...
Read more >
C# | Properties - GeeksforGeeks
The Programming languages which do not have properties, use getter and setter methods to provide such access mechanism. Using Properties.
Read more >
c# - Should a getter be allowed to return a different value than ...
Problem solved, no null values will be returned. ... Other cases where you would want to change the getter/setter value:.
Read more >
Properties | Kotlin
Getters and setters ; = 1 ; // has type Int, default getter and setter // var allByDefault // ERROR: explicit initializer required,...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found