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

Cannot Tag any Cfn objects in .NET: Could not infer JSII type for .NET type 'JArray' #3244

Closed
1 of 5 tasks
kuhnboy opened this issue Jul 8, 2019 · 7 comments · Fixed by aws/jsii#772
Closed
1 of 5 tasks
Assignees
Labels
bug This issue is a bug. language/dotnet Related to .NET bindings p0

Comments

@kuhnboy
Copy link

kuhnboy commented Jul 8, 2019

Note: for support questions, please first reference our documentation, then use Stackoverflow. This repository's issues are intended for feature requests and bug reports.

  • I'm submitting a ...

    • 🪲 bug report
    • 🚀 feature request
    • 📚 construct library gap
    • ☎️ security issue or vulnerability => Please see policy
    • ❓ support request => Please see note at the top of this template.
  • What is the current behavior?
    Any command to tag a CfnXXX object results in an exception when running cdk synth.

  • What is the expected behavior (or behavior of feature suggested)?

  • Create a new CDK project with 0.38.0-devpreview
  • Modify HelloStack to just do:
var vpc = new CfnVPC(this, "vpc", new CfnVPCProps { CidrBlock = "10.180.0.0/16", EnableDnsHostnames = true, EnableDnsSupport = true });
vpc.Node.ApplyAspect(new Tag("Name", "fooey", new TagProps()));
  • Run cdk synth
  • Exception is thrown and error is outputted
  • What is the motivation / use case for changing the behavior or adding this feature?

  • Please tell us about your environment:

    • CDK CLI Version: 1.4.0
    • Module Version: 1.4.0
    • OS: Windows 10
    • Language: C#
  • Other information (e.g. detailed explanation, stacktraces, related issues, suggestions how to fix, links for us to have context, eg. associated pull-request, stackoverflow, gitter, etc)

Amazon.JSII.Runtime.JsiiException: 'Amazon.JSII.Runtime.JsiiException: Resolution error: System.ArgumentException: Could not infer JSII type for .NET type 'JArray'
Parameter name: type
   at Amazon.JSII.Runtime.Services.Converters.FrameworkToJsiiConverter.InferType(IReferenceMap referenceMap, Type type)
   at Amazon.JSII.Runtime.Services.Converters.ValueConverter.ConvertAny(IReferenceMap referenceMap, Object value)
   at Amazon.JSII.Runtime.Services.Converters.ValueConverter.TryConvertPrimitive(IReferenceMap referenceMap, Object value, Boolean isOptional, PrimitiveType primitiveType, Object& result)
   at Amazon.JSII.Runtime.Services.Converters.ValueConverter.TryConvert(IOptionalValue optionalValue, IReferenceMap referenceMap, Object value, Object& result)
   at Amazon.JSII.Runtime.Services.Converters.FrameworkToJsiiConverter.TryConvertMap(IReferenceMap referenceMap, TypeReference elementType, Object value, Object& result)
   at Amazon.JSII.Runtime.Services.Converters.ValueConverter.TryConvert(IOptionalValue optionalValue, IReferenceMap referenceMap, Object value, Object& result)
   at Amazon.JSII.Runtime.Deputy.DeputyBase.<>c__DisplayClass20_0.<ConvertArguments>b__0(Parameter parameter, Object frameworkArgument)
   at System.Linq.Enumerable.ZipIterator[TFirst,TSecond,TResult](IEnumerable`1 first, IEnumerable`1 second, Func`3 resultSelector)+MoveNext()
   at System.Collections.Generic.LargeArrayBuilder`1.AddRange(IEnumerable`1 items)
   at System.Collections.Generic.EnumerableHelpers.ToArray[T](IEnumerable`1 source)
   at System.Linq.Enumerable.ToArray[TSource](IEnumerable`1 source)
   at Amazon.JSII.Runtime.Deputy.DeputyBase.<InvokeMethodCore>g__GetResult|18_0[T](<>c__DisplayClass18_0`1& )
   at Amazon.JSII.Runtime.Deputy.DeputyBase.InvokeMethodCore[T](JsiiMethodAttribute methodAttribute, Object[] arguments, Func`3 beginFunc, Func`3 invokeFunc)
   at Amazon.JSII.Runtime.Deputy.DeputyBase.InvokeInstanceMethod[T](Object[] arguments, String methodName).
Object creation stack:
  at new Intrinsic (C:\Users\rkuhn\AppData\Local\Temp\jsii-kernel-CY50I9\node_modules\@aws-cdk\core\lib\private\intrinsic.js:20:44)
  at new PostResolveToken (C:\Users\rkuhn\AppData\Local\Temp\jsii-kernel-CY50I9\node_modules\@aws-cdk\core\lib\util.js:72:9)
  at CfnVPC._toCloudFormation (C:\Users\rkuhn\AppData\Local\Temp\jsii-kernel-CY50I9\node_modules\@aws-cdk\core\lib\cfn-resource.js:167:39)
  at node.addReference.resolve_1.findTokens (C:\Users\rkuhn\AppData\Local\Temp\jsii-kernel-CY50I9\node_modules\@aws-cdk\core\lib\cfn-element.js:84:77)
  at Object.findTokens (C:\Users\rkuhn\AppData\Local\Temp\jsii-kernel-CY50I9\node_modules\@aws-cdk\core\lib\private\resolve.js:125:13)
  at CfnVPC.prepare (C:\Users\rkuhn\AppData\Local\Temp\jsii-kernel-CY50I9\node_modules\@aws-cdk\core\lib\cfn-element.js:84:49)
  at _wrapSandboxCode (C:\Users\rkuhn\AppData\Local\Temp\w1ejir4g.h30\jsii-runtime.js:6493:51)
  at Kernel._wrapSandboxCode (C:\Users\rkuhn\AppData\Local\Temp\w1ejir4g.h30\jsii-runtime.js:7126:20)
  at ret._ensureSync (C:\Users\rkuhn\AppData\Local\Temp\w1ejir4g.h30\jsii-runtime.js:6493:25)
  at Kernel._ensureSync (C:\Users\rkuhn\AppData\Local\Temp\w1ejir4g.h30\jsii-runtime.js:7097:20)
  at Kernel.invoke (C:\Users\rkuhn\AppData\Local\Temp\w1ejir4g.h30\jsii-runtime.js:6492:26)
  at KernelHost.processRequest (C:\Users\rkuhn\AppData\Local\Temp\w1ejir4g.h30\jsii-runtime.js:6186:28)
  at completeCallback (C:\Users\rkuhn\AppData\Local\Temp\w1ejir4g.h30\jsii-runtime.js:6159:25)
  at KernelHost.callbackHandler (C:\Users\rkuhn\AppData\Local\Temp\w1ejir4g.h30\jsii-runtime.js:6140:16)
  at KernelHost.kernel.jsii_kernel_1.Kernel.cb [as callbackHandler] (C:\Users\rkuhn\AppData\Local\Temp\w1ejir4g.h30\jsii-runtime.js:6124:59)
  at CfnVPC.value (C:\Users\rkuhn\AppData\Local\Temp\w1ejir4g.h30\jsii-runtime.js:6843:41)
  at Function.prepare (C:\Users\rkuhn\AppData\Local\Temp\jsii-kernel-CY50I9\node_modules\@aws-cdk\core\lib\construct.js:89:27)
  at Function.synth (C:\Users\rkuhn\AppData\Local\Temp\jsii-kernel-CY50I9\node_modules\@aws-cdk\core\lib\construct.js:52:14)
  at App.synth (C:\Users\rkuhn\AppData\Local\Temp\jsii-kernel-CY50I9\node_modules\@aws-cdk\core\lib\app.js:67:52)
  at _wrapSandboxCode (C:\Users\rkuhn\AppData\Local\Temp\w1ejir4g.h30\jsii-runtime.js:6493:51)
  at Kernel._wrapSandboxCode (C:\Users\rkuhn\AppData\Local\Temp\w1ejir4g.h30\jsii-runtime.js:7126:20)
  at ret._ensureSync (C:\Users\rkuhn\AppData\Local\Temp\w1ejir4g.h30\jsii-runtime.js:6493:25)
  at Kernel._ensureSync (C:\Users\rkuhn\AppData\Local\Temp\w1ejir4g.h30\jsii-runtime.js:7097:20)
  at Kernel.invoke (C:\Users\rkuhn\AppData\Local\Temp\w1ejir4g.h30\jsii-runtime.js:6492:26)
  at KernelHost.processRequest (C:\Users\rkuhn\AppData\Local\Temp\w1ejir4g.h30\jsii-runtime.js:6186:28)
  at KernelHost.run (C:\Users\rkuhn\AppData\Local\Temp\w1ejir4g.h30\jsii-runtime.js:6132:14)
  at processRequest (C:\Users\rkuhn\AppData\Local\Temp\w1ejir4g.h30\jsii-runtime.js:6132:45)
  at KernelHost.processRequest (C:\Users\rkuhn\AppData\Local\Temp\w1ejir4g.h30\jsii-runtime.js:6228:16)
  at KernelHost.run (C:\Users\rkuhn\AppData\Local\Temp\w1ejir4g.h30\jsii-runtime.js:6132:14)
  at processRequest (C:\Users\rkuhn\AppData\Local\Temp\w1ejir4g.h30\jsii-runtime.js:6132:45)
  at KernelHost.processRequest (C:\Users\rkuhn\AppData\Local\Temp\w1ejir4g.h30\jsii-runtime.js:6228:16)
  at KernelHost.run (C:\Users\rkuhn\AppData\Local\Temp\w1ejir4g.h30\jsii-runtime.js:6132:14)
  at processRequest (C:\Users\rkuhn\AppData\Local\Temp\w1ejir4g.h30\jsii-runtime.js:6132:45)
  at KernelHost.processRequest (C:\Users\rkuhn\AppData\Local\Temp\w1ejir4g.h30\jsii-runtime.js:6228:16)
  at KernelHost.run (C:\Users\rkuhn\AppData\Local\Temp\w1ejir4g.h30\jsii-runtime.js:6132:14)
  at processRequest (C:\Users\rkuhn\AppData\Local\Temp\w1ejir4g.h30\jsii-runtime.js:6132:45)
  at KernelHost.processRequest (C:\Users\rkuhn\AppData\Local\Temp\w1ejir4g.h30\jsii-runtime.js:6228:16)
  at KernelHost.run (C:\Users\rkuhn\AppData\Local\Temp\w1ejir4g.h30\jsii-runtime.js:6132:14)
  at processRequest (C:\Users\rkuhn\AppData\Local\Temp\w1ejir4g.h30\jsii-runtime.js:6132:45)
  at KernelHost.processRequest (C:\Users\rkuhn\AppData\Local\Temp\w1ejir4g.h30\jsii-runtime.js:6228:16)
  at KernelHost.run (C:\Users\rkuhn\AppData\Local\Temp\w1ejir4g.h30\jsii-runtime.js:6132:14)
  at processRequest (C:\Users\rkuhn\AppData\Local\Temp\w1ejir4g.h30\jsii-runtime.js:6132:45)
  at promise.then.val (C:\Users\rkuhn\AppData\Local\Temp\w1ejir4g.h30\jsii-runtime.js:6213:21)
  at <anonymous>
   at Amazon.JSII.Runtime.Services.Client.TryDeserialize[TResponse](String responseJson)
   at Amazon.JSII.Runtime.Services.Client.ReceiveResponse[TResponse]()
   at Amazon.JSII.Runtime.Services.Client.TryDeserialize[TResponse](String responseJson)
   at Amazon.JSII.Runtime.Services.Client.ReceiveResponse[TResponse]()
   at Amazon.JSII.Runtime.Deputy.DeputyBase.<InvokeMethodCore>g__GetResult|18_0[T](<>c__DisplayClass18_0`1& )
   at Amazon.JSII.Runtime.Deputy.DeputyBase.InvokeMethodCore[T](JsiiMethodAttribute methodAttribute, Object[] arguments, Func`3 beginFunc, Func`3 invokeFunc)
   at Amazon.JSII.Runtime.Deputy.DeputyBase.InvokeInstanceMethod[T](Object[] arguments, String methodName)
   at Amazon.CDK.CfnElement.Prepare()'

EDIT - (NGL321): Updated to reflect bug exists in current builds

@kuhnboy kuhnboy added the needs-triage This issue or PR still needs to be triaged. label Jul 8, 2019
@kuhnboy
Copy link
Author

kuhnboy commented Jul 8, 2019

Occurred when testing the fix for: #3093

@kuhnboy
Copy link
Author

kuhnboy commented Jul 11, 2019

This is a big blocker when all of our resources in AWS have one or more tags.

@kknd4eva
Copy link

Just wondering if anyone has a workaround for this issue? Apart from downgrading the version? It seems no matter where/when I cast a list of (for instance) security groups to a string array, it breaks during synth.

@kuhnboy
Copy link
Author

kuhnboy commented Jul 31, 2019

Currently, I've had to downgrade to 0.28.0

@NGL321
Copy link
Contributor

NGL321 commented Aug 15, 2019

@McDoit this issue looks like the problem you were encountering.

#3672 Recent duplicate

@NGL321 NGL321 added language/dotnet Related to .NET bindings bug This issue is a bug. @aws-cdk/aws-cloudformation Related to AWS CloudFormation and removed needs-triage This issue or PR still needs to be triaged. labels Aug 15, 2019
@McDoit
Copy link
Contributor

McDoit commented Aug 16, 2019

I guess it might be the same for the SecurityGroupIds case, the stacktrace looks the same, so i hope this will fix that one as well.
But om glad that 0.28 is as stable as it is, even if it is missing some features

@NGL321 NGL321 self-assigned this Aug 16, 2019
@vachumakov
Copy link

I have same issue with CfnTargetGroup and CfnListenerRule. I believe any CfnXXX object which has property with type array cause this exception

@eladb eladb removed the @aws-cdk/aws-cloudformation Related to AWS CloudFormation label Sep 4, 2019
@fulghum fulghum added the p0 label Sep 10, 2019
@eladb eladb assigned RomainMuller and unassigned eladb and NGL321 Sep 11, 2019
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
bug This issue is a bug. language/dotnet Related to .NET bindings p0
Projects
None yet
8 participants