Aws-cdk: C#: Calling grant on a EncryptionKey throws Parameter count mismatch

Created on 25 Apr 2019  路  7Comments  路  Source: aws/aws-cdk

Describe the bug
Calling testKey.GrantEncryptDecrypt(new Anyone()); throws System.Reflection.TargetParameterCountException: Parameter count mismatch.
on the GrantEncryptDecrypt or any Grant part

To Reproduce
````
var testKey = new EncryptionKey(this, "key", new EncryptionKeyProps
{
Description = "test key",
EnableKeyRotation = false,
Enabled = true,
Retain = false
});

            testKey.GrantEncryptDecrypt(new Anyone());

````

Expected behavior
The grant to happen, worked in 0.28

Version:

  • Windows 10
  • dotnet core 2.1, C#
  • 0.29
bug languagdotnet p1

All 7 comments

I'm having the same error message when trying to add a SqsEventSource. v0.31

Having save error when trying to addContainer to taskDefinition

Was able to repro using:

            var testKey = new Key(stack, "key", new KeyProps()
            {
                Description = "test key",
                EnableKeyRotation = false,
                Enabled = true,
            });

            testKey.GrantEncryptDecrypt(new Anyone());

After some investigation:

relates https://github.com/aws/jsii/issues/404

When deserializing callback arguments, the wrong number of arguments get passed to the callback method here:

https://github.com/aws/jsii/blob/2f40eeb7c60ffe205507891797885a9de9e9db65/packages/jsii-dotnet-runtime/src/Amazon.JSII.Runtime/CallbackExtensions.cs#L81

In the above GrantEncryptDecrypt() example, a callback to Grant() is created, with 5 arguments. The first is an IIGrantable and the other fives are strings. They should have been casted as an array of string[]

The signature for Grant() is:

Grant(IIGrantable grantee, params string[] actions)

Hence the blow up.

Original root cause:

https://github.com/aws/jsii/blob/2f40eeb7c60ffe205507891797885a9de9e9db65/packages/jsii-dotnet-runtime/src/Amazon.JSII.Runtime/CallbackExtensions.cs#L131

I am lacking background on the matter. Any idea @RomainMuller ?

Hitting this issue as well

This might be fixed in the next version.

This should be fixed on the current release!

Was this page helpful?
0 / 5 - 0 ratings