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

jsii/java issue - CfnTag: argument type mismatch #1717

Closed
sai-tirunagiri opened this issue Feb 9, 2019 · 5 comments
Closed

jsii/java issue - CfnTag: argument type mismatch #1717

sai-tirunagiri opened this issue Feb 9, 2019 · 5 comments
Assignees
Labels
bug This issue is a bug. language/java Related to Java bindings

Comments

@sai-tirunagiri
Copy link

Hi, Today I upgraded the cdk libraries from 0.23.0 -> 0.24.1 and made the changes from cdk.Tag to cdk.CfnTag post this change upon doing cdk synth ended up getting an argument type mismatch error.

source code:

tag = CfnTag.builder().withKey("key_name").withValue("tag_value").build();
tagList.add(tag);

CfnVPCProps.builder().withTags(tagList).build();

any solution to solve argument type mismatch error.?

cdk pom version : 0.24.1
cdk version : 0.24.1

@eladb
Copy link
Contributor

eladb commented Feb 10, 2019

Seems like a bug in how tags passed into properties of L1s interact with that recently added TagManager object in Java.

As a workaround, you could directly access the tag manager like this:

CfnVPC vpc = new CfnVPC(this, "MyVpc", CfnVPCProps.builder()
    .withCidrBlock("0.0.0.0/0")
    .build());

vpc.getTags().setTag("Hello", "Value");

Copy @moofish32

@eladb eladb added bug This issue is a bug. language/java Related to Java bindings @aws-cdk/core Related to core CDK functionality labels Feb 10, 2019
@eladb
Copy link
Contributor

eladb commented Feb 11, 2019

Oddly, when trying to produce a jsii dump (using JSII_DEBUG=1) to repro this, the test passes:

/Library/Java/JavaVirtualMachines/jdk-9.0.4.jdk/Contents/Home/bin/java -ea -Didea.test.cyclic.buffer.size=1048576 "-javaagent:/Applications/IntelliJ IDEA CE.app/Contents/lib/idea_rt.jar=55159:/Applications/IntelliJ IDEA CE.app/Contents/bin" -Dfile.encoding=UTF-8 -classpath "/Applications/IntelliJ IDEA CE.app/Contents/lib/idea_rt.jar:/Applications/IntelliJ IDEA CE.app/Contents/plugins/junit/lib/junit-rt.jar:/Applications/IntelliJ IDEA CE.app/Contents/plugins/junit/lib/junit5-rt.jar:/Users/benisrae/playground/pg-113/target/test-classes:/Users/benisrae/playground/pg-113/target/classes:/Users/benisrae/.m2/repository/software/amazon/awscdk/cdk/0.24.0/cdk-0.24.0.jar:/Users/benisrae/.m2/repository/software/amazon/awscdk/cdk-cx-api/0.24.0/cdk-cx-api-0.24.0.jar:/Users/benisrae/.m2/repository/software/amazon/jsii/jsii-runtime/0.7.14/jsii-runtime-0.7.14.jar:/Users/benisrae/.m2/repository/com/fasterxml/jackson/core/jackson-core/2.9.5/jackson-core-2.9.5.jar:/Users/benisrae/.m2/repository/com/fasterxml/jackson/core/jackson-databind/2.9.5/jackson-databind-2.9.5.jar:/Users/benisrae/.m2/repository/com/fasterxml/jackson/core/jackson-annotations/2.9.0/jackson-annotations-2.9.0.jar:/Users/benisrae/.m2/repository/com/google/guava/guava-io/r03/guava-io-r03.jar:/Users/benisrae/.m2/repository/com/google/guava/guava-annotations/r03/guava-annotations-r03.jar:/Users/benisrae/.m2/repository/com/google/guava/guava-base/r03/guava-base-r03.jar:/Users/benisrae/.m2/repository/com/google/code/findbugs/jsr305/3.0.2/jsr305-3.0.2.jar:/Users/benisrae/.m2/repository/software/amazon/awscdk/iam/0.24.0/iam-0.24.0.jar:/Users/benisrae/.m2/repository/software/amazon/awscdk/s3/0.24.0/s3-0.24.0.jar:/Users/benisrae/.m2/repository/software/amazon/awscdk/codepipeline-api/0.24.0/codepipeline-api-0.24.0.jar:/Users/benisrae/.m2/repository/software/amazon/awscdk/events/0.24.0/events-0.24.0.jar:/Users/benisrae/.m2/repository/software/amazon/awscdk/kms/0.24.0/kms-0.24.0.jar:/Users/benisrae/.m2/repository/software/amazon/awscdk/s3-notifications/0.24.0/s3-notifications-0.24.0.jar:/Users/benisrae/.m2/repository/software/amazon/awscdk/sns/0.24.0/sns-0.24.0.jar:/Users/benisrae/.m2/repository/software/amazon/awscdk/autoscaling-api/0.24.0/autoscaling-api-0.24.0.jar:/Users/benisrae/.m2/repository/software/amazon/awscdk/cloudwatch/0.24.0/cloudwatch-0.24.0.jar:/Users/benisrae/.m2/repository/software/amazon/awscdk/lambda/0.24.0/lambda-0.24.0.jar:/Users/benisrae/.m2/repository/software/amazon/awscdk/cdk-assets/0.24.0/cdk-assets-0.24.0.jar:/Users/benisrae/.m2/repository/software/amazon/awscdk/ec2/0.24.0/ec2-0.24.0.jar:/Users/benisrae/.m2/repository/software/amazon/awscdk/stepfunctions/0.24.0/stepfunctions-0.24.0.jar:/Users/benisrae/.m2/repository/software/amazon/awscdk/cloudtrail/0.24.0/cloudtrail-0.24.0.jar:/Users/benisrae/.m2/repository/software/amazon/awscdk/logs/0.24.0/logs-0.24.0.jar:/Users/benisrae/.m2/repository/software/amazon/awscdk/sqs/0.24.0/sqs-0.24.0.jar:/Users/benisrae/.m2/repository/junit/junit/4.12/junit-4.12.jar:/Users/benisrae/.m2/repository/org/hamcrest/hamcrest-core/1.3/hamcrest-core-1.3.jar" com.intellij.rt.execution.junit.JUnitStarter -ideVersion5 -junit4 com.myorg.HelloStackTest,testStack
jsii-runtime: /var/folders/n2/6v4_tbz97ws0h4bn5gbyvzb0m8vcjb/T/jsii-java-runtime5481812854297521148/jsii-runtime.js
> {"api":"load","tarball":"/var/folders/n2/6v4_tbz97ws0h4bn5gbyvzb0m8vcjb/T/jsii-java-runtime-resource10659285574129354055/cx-api@0.24.0.jsii.tgz","name":"@aws-cdk/cx-api","version":"0.24.0"}
[jsii-kernel] load { api: 'load',
  tarball:
   '/var/folders/n2/6v4_tbz97ws0h4bn5gbyvzb0m8vcjb/T/jsii-java-runtime-resource10659285574129354055/cx-api@0.24.0.jsii.tgz',
  name: '@aws-cdk/cx-api',
  version: '0.24.0' }
waiting for promise to be fulfilled
[jsii-kernel] creating jsii-kernel modules workdir: /var/folders/n2/6v4_tbz97ws0h4bn5gbyvzb0m8vcjb/T/jsii-kernel-tRXZuI
[jsii-kernel] removing staging directory: /var/folders/n2/6v4_tbz97ws0h4bn5gbyvzb0m8vcjb/T/jsii-kernel-install-staging-pxYv37
promise succeeded: { assembly: '@aws-cdk/cx-api', types: 13 }
< {"ok":{"assembly":"@aws-cdk/cx-api","types":13}}
> {"api":"load","tarball":"/var/folders/n2/6v4_tbz97ws0h4bn5gbyvzb0m8vcjb/T/jsii-java-runtime-resource5174660413330668099/cdk@0.24.0.jsii.tgz","name":"@aws-cdk/cdk","version":"0.24.0"}
[jsii-kernel] load { api: 'load',
  tarball:
   '/var/folders/n2/6v4_tbz97ws0h4bn5gbyvzb0m8vcjb/T/jsii-java-runtime-resource5174660413330668099/cdk@0.24.0.jsii.tgz',
  name: '@aws-cdk/cdk',
  version: '0.24.0' }
waiting for promise to be fulfilled
[jsii-kernel] removing staging directory: /var/folders/n2/6v4_tbz97ws0h4bn5gbyvzb0m8vcjb/T/jsii-kernel-install-staging-1Xgcl2
promise succeeded: { assembly: '@aws-cdk/cdk', types: 79 }
< {"ok":{"assembly":"@aws-cdk/cdk","types":79}}
> {"fqn":"@aws-cdk/cdk.App","args":[],"overrides":[],"api":"create"}
[jsii-kernel] overrides []
< {"ok":{"$jsii.byref":"@aws-cdk/cdk.App@10000"}}
> {"fqn":"@aws-cdk/cdk.Stack","args":[{"$jsii.byref":"@aws-cdk/cdk.App@10000"},"test",null],"overrides":[],"api":"create"}
[jsii-kernel] findObject @aws-cdk/cdk.App@10000
[jsii-kernel] overrides []
< {"ok":{"$jsii.byref":"@aws-cdk/cdk.Stack@10001"}}
> {"api":"load","tarball":"/var/folders/n2/6v4_tbz97ws0h4bn5gbyvzb0m8vcjb/T/jsii-java-runtime-resource14007481800365077786/aws-iam@0.24.0.jsii.tgz","name":"@aws-cdk/aws-iam","version":"0.24.0"}
[jsii-kernel] load { api: 'load',
  tarball:
   '/var/folders/n2/6v4_tbz97ws0h4bn5gbyvzb0m8vcjb/T/jsii-java-runtime-resource14007481800365077786/aws-iam@0.24.0.jsii.tgz',
  name: '@aws-cdk/aws-iam',
  version: '0.24.0' }
waiting for promise to be fulfilled
[jsii-kernel] removing staging directory: /var/folders/n2/6v4_tbz97ws0h4bn5gbyvzb0m8vcjb/T/jsii-kernel-install-staging-0UL0EO
promise succeeded: { assembly: '@aws-cdk/aws-iam', types: 49 }
< {"ok":{"assembly":"@aws-cdk/aws-iam","types":49}}
> {"api":"load","tarball":"/var/folders/n2/6v4_tbz97ws0h4bn5gbyvzb0m8vcjb/T/jsii-java-runtime-resource689381528375547086/aws-ec2@0.24.0.jsii.tgz","name":"@aws-cdk/aws-ec2","version":"0.24.0"}
[jsii-kernel] load { api: 'load',
  tarball:
   '/var/folders/n2/6v4_tbz97ws0h4bn5gbyvzb0m8vcjb/T/jsii-java-runtime-resource689381528375547086/aws-ec2@0.24.0.jsii.tgz',
  name: '@aws-cdk/aws-ec2',
  version: '0.24.0' }
waiting for promise to be fulfilled
[jsii-kernel] removing staging directory: /var/folders/n2/6v4_tbz97ws0h4bn5gbyvzb0m8vcjb/T/jsii-kernel-install-staging-mcGYs8
promise succeeded: { assembly: '@aws-cdk/aws-ec2', types: 227 }
< {"ok":{"assembly":"@aws-cdk/aws-ec2","types":227}}
> {"api":"sget","fqn":"@aws-cdk/aws-ec2.CfnVPC","property":"resourceTypeName"}
[jsii-kernel] sget @aws-cdk/aws-ec2.CfnVPC.resourceTypeName
[jsii-kernel] value: AWS::EC2::VPC
[jsii-kernel] fromSandbox AWS::EC2::VPC { primitive: 'string' }
[jsii-kernel] primitive AWS::EC2::VPC
[jsii-kernel] ret AWS::EC2::VPC
< {"ok":{"value":"AWS::EC2::VPC"}}
> {"fqn":"Object","args":[],"overrides":[{"property":"instanceTenancy"},{"property":"cidrBlock"},{"property":"enableDnsSupport"},{"property":"enableDnsHostnames"},{"property":"tags"}],"api":"create"}
[jsii-kernel] overrides [ { property: 'instanceTenancy' },
  { property: 'cidrBlock' },
  { property: 'enableDnsSupport' },
  { property: 'enableDnsHostnames' },
  { property: 'tags' } ]
[jsii-kernel] apply override instanceTenancy
[jsii-kernel] apply override cidrBlock
[jsii-kernel] apply override enableDnsSupport
[jsii-kernel] apply override enableDnsHostnames
[jsii-kernel] apply override tags
< {"ok":{"$jsii.byref":"Object@10002"}}
> {"fqn":"@aws-cdk/aws-ec2.CfnVPC","args":[{"$jsii.byref":"@aws-cdk/cdk.Stack@10001"},"MyVpc",{"$jsii.byref":"Object@10002"}],"overrides":[],"api":"create"}
[jsii-kernel] findObject @aws-cdk/cdk.Stack@10001
[jsii-kernel] findObject Object@10002
< {"callback":{"cbid":"jsii::callback::10003","get":{"objref":{"$jsii.byref":"Object@10002"},"property":"cidrBlock"}}}
> {"complete":{"cbid":"jsii::callback::10003","result":"0.0.0.0/0"}}
[jsii-kernel] callback returned 0.0.0.0/0
[jsii-kernel] overrides []
< {"ok":{"$jsii.byref":"@aws-cdk/aws-ec2.CfnVPC@10004"}}
> {"api":"get","objref":{"$jsii.byref":"@aws-cdk/cdk.Stack@10001"},"property":"name"}
[jsii-kernel] get { '$jsii.byref': '@aws-cdk/cdk.Stack@10001' } name
[jsii-kernel] findObject @aws-cdk/cdk.Stack@10001
[jsii-kernel] value: test
[jsii-kernel] fromSandbox test { primitive: 'string' }
[jsii-kernel] primitive test
[jsii-kernel] ret: test
< {"ok":{"value":"test"}}
> {"api":"invoke","objref":{"$jsii.byref":"@aws-cdk/cdk.App@10000"},"method":"synthesizeStack","args":["test"]}
[jsii-kernel] invoke { '$jsii.byref': '@aws-cdk/cdk.App@10000' } synthesizeStack [ 'test' ]
[jsii-kernel] findObject @aws-cdk/cdk.App@10000
< {"callback":{"cbid":"jsii::callback::10005","get":{"objref":{"$jsii.byref":"Object@10002"},"property":"tags"}}}
> {"fqn":"Object","args":[],"overrides":[{"property":"value"},{"property":"key"}],"api":"create"}
[jsii-kernel] overrides [ { property: 'value' }, { property: 'key' } ]
[jsii-kernel] apply override value
[jsii-kernel] apply override key
< {"ok":{"$jsii.byref":"Object@10006"}}
> {"complete":{"cbid":"jsii::callback::10005","result":[{"$jsii.byref":"Object@10006"}]}}
[jsii-kernel] callback returned [ { '$jsii.byref': 'Object@10006' } ]
[jsii-kernel] findObject Object@10006
[jsii-kernel] virtual set { '$jsii.byref': 'Object@10002' } tags { cookie: undefined }
[jsii-kernel] fromSandbox [ { value: [Getter/Setter], key: [Getter/Setter] } ] undefined
[jsii-kernel] array [ { value: [Getter/Setter], key: [Getter/Setter] } ]
[jsii-kernel] fromSandbox { value: [Getter/Setter], key: [Getter/Setter] } undefined
[jsii-kernel] objref exists Object@10006
< {"callback":{"cbid":"jsii::callback::10007","set":{"objref":{"$jsii.byref":"Object@10002"},"property":"tags","value":[{"$jsii.byref":"Object@10006"}]}}}
> {"complete":{"cbid":"jsii::callback::10007"}}
< {"callback":{"cbid":"jsii::callback::10008","get":{"objref":{"$jsii.byref":"Object@10002"},"property":"instanceTenancy"}}}
> {"complete":{"cbid":"jsii::callback::10008"}}
[jsii-kernel] callback returned undefined
< {"callback":{"cbid":"jsii::callback::10009","get":{"objref":{"$jsii.byref":"Object@10002"},"property":"cidrBlock"}}}
> {"complete":{"cbid":"jsii::callback::10009","result":"0.0.0.0/0"}}
[jsii-kernel] callback returned 0.0.0.0/0
< {"callback":{"cbid":"jsii::callback::10010","get":{"objref":{"$jsii.byref":"Object@10002"},"property":"enableDnsSupport"}}}
> {"complete":{"cbid":"jsii::callback::10010"}}
[jsii-kernel] callback returned undefined
< {"callback":{"cbid":"jsii::callback::10011","get":{"objref":{"$jsii.byref":"Object@10002"},"property":"enableDnsHostnames"}}}
> {"complete":{"cbid":"jsii::callback::10011"}}
[jsii-kernel] callback returned undefined
< {"callback":{"cbid":"jsii::callback::10012","get":{"objref":{"$jsii.byref":"Object@10002"},"property":"tags"}}}
> {"complete":{"cbid":"jsii::callback::10012","result":[{"$jsii.byref":"Object@10006"}]}}
[jsii-kernel] callback returned [ { '$jsii.byref': 'Object@10006' } ]
[jsii-kernel] findObject Object@10006
< {"callback":{"cbid":"jsii::callback::10013","get":{"objref":{"$jsii.byref":"Object@10006"},"property":"value"}}}
> {"complete":{"cbid":"jsii::callback::10013","result":"BBB"}}
[jsii-kernel] callback returned BBB
< {"callback":{"cbid":"jsii::callback::10014","get":{"objref":{"$jsii.byref":"Object@10006"},"property":"key"}}}
> {"complete":{"cbid":"jsii::callback::10014","result":"AAA"}}
[jsii-kernel] callback returned AAA
< {"callback":{"cbid":"jsii::callback::10015","get":{"objref":{"$jsii.byref":"Object@10002"},"property":"tags"}}}
> {"complete":{"cbid":"jsii::callback::10015","result":[{"$jsii.byref":"Object@10006"}]}}
[jsii-kernel] callback returned [ { '$jsii.byref': 'Object@10006' } ]
[jsii-kernel] findObject Object@10006
[jsii-kernel] virtual set { '$jsii.byref': 'Object@10002' } tags { cookie: undefined }
[jsii-kernel] fromSandbox [ { value: [Getter/Setter], key: [Getter/Setter] } ] undefined
[jsii-kernel] array [ { value: [Getter/Setter], key: [Getter/Setter] } ]
[jsii-kernel] fromSandbox { value: [Getter/Setter], key: [Getter/Setter] } undefined
[jsii-kernel] objref exists Object@10006
< {"callback":{"cbid":"jsii::callback::10016","set":{"objref":{"$jsii.byref":"Object@10002"},"property":"tags","value":[{"$jsii.byref":"Object@10006"}]}}}
> {"complete":{"cbid":"jsii::callback::10016"}}
< {"callback":{"cbid":"jsii::callback::10017","get":{"objref":{"$jsii.byref":"Object@10002"},"property":"instanceTenancy"}}}
> {"complete":{"cbid":"jsii::callback::10017"}}
[jsii-kernel] callback returned undefined
< {"callback":{"cbid":"jsii::callback::10018","get":{"objref":{"$jsii.byref":"Object@10002"},"property":"cidrBlock"}}}
> {"complete":{"cbid":"jsii::callback::10018","result":"0.0.0.0/0"}}
[jsii-kernel] callback returned 0.0.0.0/0
< {"callback":{"cbid":"jsii::callback::10019","get":{"objref":{"$jsii.byref":"Object@10002"},"property":"enableDnsSupport"}}}
> {"complete":{"cbid":"jsii::callback::10019"}}
[jsii-kernel] callback returned undefined
< {"callback":{"cbid":"jsii::callback::10020","get":{"objref":{"$jsii.byref":"Object@10002"},"property":"enableDnsHostnames"}}}
> {"complete":{"cbid":"jsii::callback::10020"}}
[jsii-kernel] callback returned undefined
< {"callback":{"cbid":"jsii::callback::10021","get":{"objref":{"$jsii.byref":"Object@10002"},"property":"tags"}}}
> {"complete":{"cbid":"jsii::callback::10021","result":[{"$jsii.byref":"Object@10006"}]}}
[jsii-kernel] callback returned [ { '$jsii.byref': 'Object@10006' } ]
[jsii-kernel] findObject Object@10006
< {"callback":{"cbid":"jsii::callback::10022","get":{"objref":{"$jsii.byref":"Object@10006"},"property":"value"}}}
> {"complete":{"cbid":"jsii::callback::10022","result":"BBB"}}
[jsii-kernel] callback returned BBB
< {"callback":{"cbid":"jsii::callback::10023","get":{"objref":{"$jsii.byref":"Object@10006"},"property":"key"}}}
> {"complete":{"cbid":"jsii::callback::10023","result":"AAA"}}
[jsii-kernel] callback returned AAA
[jsii-kernel] fromSandbox { name: 'test',
  environment:
   { name: 'unknown-account/unknown-region',
     account: 'unknown-account',
     region: 'unknown-region' },
  missing: undefined,
  template: { Resources: { MyVpc: [Object] } },
  metadata: { '/test/MyVpc': [ [Object] ] },
  dependsOn: undefined } { fqn: '@aws-cdk/cx-api.SynthesizedStack' }
[jsii-kernel] coalescing to { fqn: '@aws-cdk/cx-api.SynthesizedStack' }
< {"ok":{"result":{"$jsii.byref":"@aws-cdk/cx-api.SynthesizedStack@10024"}}}
> {"api":"naming","assembly":"@aws-cdk/cx-api"}
[jsii-kernel] naming @aws-cdk/cx-api
< {"ok":{"naming":{"dotnet":{"assemblyOriginatorKeyFile":"../../key.snk","namespace":"Amazon.CDK.CXAPI","packageId":"Amazon.CDK.CXAPI","signAssembly":true},"java":{"maven":{"artifactId":"cdk-cx-api","groupId":"software.amazon.awscdk"},"package":"software.amazon.awscdk.cxapi"},"js":{"npm":"@aws-cdk/cx-api"}}}}
> {"api":"get","objref":{"$jsii.byref":"@aws-cdk/cx-api.SynthesizedStack@10024"},"property":"template"}
< {"ok":{"value":{"Resources":{"MyVpc":{"Type":"AWS::EC2::VPC","Properties":{"CidrBlock":"0.0.0.0/0","Tags":[{"Key":"AAA","Value":"BBB"}]}}}}}}
{"Resources":{"MyVpc":{"Type":"AWS::EC2::VPC","Properties":{"CidrBlock":"0.0.0.0/0","Tags":[{"Value":"BBB","Key":"AAA"}]}}}}

Process finished with exit code 0

@eladb eladb changed the title CfnTag: argument type mismatch jsii/java issue - CfnTag: argument type mismatch Feb 11, 2019
@moofish32
Copy link
Contributor

moofish32 commented Feb 11, 2019

@eladb The actual tag property from code generation is like:

    /**
     * ``AWS::Lambda::Function.Tags``
     * @link http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-lambda-function.html#cfn-lambda-function-tags
     */
    tags?: Array<cdk.CfnTag | cdk.Token> | cdk.Token;

The TagManager is obviously a different type. Then in resource.ts there is this piece: https://github.com/awslabs/aws-cdk/blob/v0.24.1/packages/%40aws-cdk/cdk/lib/cloudformation/resource.ts#L209-L212

properties.tags is set to what I expect to be a valid structure (an array of CfnTag, but perhaps there is an error or num2str type of conversion?), but I am suspicious if we don't somewhere cross the wires on the type of tags. I haven't had a chance to dig deeper, but that's what I thought of when I saw this issue.

@moofish32
Copy link
Contributor

@eladb another interesting thing about this bug:

//        CfnQueue cfn = new CfnQueue(this, "RawQueue", CfnQueueProps.builder().withTags(tags).build());
        CfnQueue cfn = new CfnQueue(this, "RawQueue");
        cfn.apply(new Tag("Yay", "Aspects"));

If you switch the commented out queue with the current queue the behavior changes. The queue with props throws the error.

@eladb eladb removed the @aws-cdk/core Related to core CDK functionality label Mar 4, 2019
@eladb eladb self-assigned this Apr 2, 2019
@eladb
Copy link
Contributor

eladb commented Apr 4, 2019

Verified that this has been resolved in 0.28.0

@eladb eladb closed this as completed Apr 4, 2019
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/java Related to Java bindings
Projects
None yet
Development

No branches or pull requests

3 participants