Skip to content

.NET CDK 1.16.2 JsiiException exception on synth at CodeCommit.Repository.OnCommit #4989

@vgribok

Description

@vgribok

After upgrading my working simple CI/CD CDK project from .NET CDK 1.11.0 to CDK 1.16.2, I started getting an exception with message:

Amazon.JSII.Runtime.JsiiException: Amazon.JSII.Runtime.JsiiException: Amazon.JSII.Runtime.JsiiException: System.InvalidCastException: Unable to cast Amazon.JSII.Runtime.Deputy.AnonymousObject into Amazon.CDK.AWS.Events.IOnEventOptions

Reproduction Steps

Plug the snippet below into your .NET CDK project and run it to see the exception.

private static Pipeline CreateCiCdPipeline(Construct parent)
{
    const string appName = "My-Application";

    Artifact_ sourceCodeArtifact = new Artifact_("Visual-Studio-Solution");

    Vcs.Repository gitRepo = new Vcs.Repository(parent, "CodeCommitRepo",
        new Vcs.RepositoryProps
        {
            RepositoryName = "My-CodeCommit-Repo",
            Description = $"Version control system for {appName} application"
        }
    );

    var buildPipeline = new Pipeline(parent, "BuildPipeline",
        new PipelineProps
        {
            PipelineName = appName,
            Stages = new[]
            {
                new StageProps
                {
                    StageName = "Source",
                    Actions = new [] {
                        new CodeCommitSourceAction(new CodeCommitSourceActionProps
                        {
                            ActionName = "Git-checkout-from-CodeCommit-repo",
                            Repository = gitRepo,
                            Output = sourceCodeArtifact,
                            Branch = "master",
                        })
                    }
                }
            }
        }
    );

    return buildPipeline;
}

Error Log

Amazon.JSII.Runtime.JsiiException: Amazon.JSII.Runtime.JsiiException: Amazon.JSII.Runtime.JsiiException: System.InvalidCastException: Unable to cast Amazon.JSII.Runtime.Deputy.AnonymousObject into Amazon.CDK.AWS.Events.IOnEventOptions

Environment

  • **CLI Version :1.16.2 (build 5893301)
  • **Framework Version:3.0
  • **OS :Windows 10 Build 17763.805
  • **Language :C#

Other

Stack Trace

Amazon.JSII.Runtime.JsiiException: Amazon.JSII.Runtime.JsiiException: Amazon.JSII.Runtime.JsiiException: System.InvalidCastException: Unable to cast Amazon.JSII.Runtime.Deputy.AnonymousObject into Amazon.CDK.AWS.Events.IOnEventOptions
at Amazon.JSII.Runtime.Deputy.DeputyBase.ToType(Type conversionType, IFormatProvider provider)
at System.Convert.ChangeType(Object value, Type conversionType, IFormatProvider provider)
at System.Convert.ChangeType(Object value, Type conversionType)
at Amazon.JSII.Runtime.Services.Converters.JsiiToFrameworkConverter.TryConvertClass(Type type, IReferenceMap referenceMap, Object value, Object& result)
at Amazon.JSII.Runtime.Services.Converters.ValueConverter.TryConvertCustomType(Type type, IReferenceMap referenceMap, Object value, Boolean isOptional, String fullyQualifiedName, Object& result)
at Amazon.JSII.Runtime.Services.Converters.ValueConverter.TryConvert(IOptionalValue optionalValue, Type type, IReferenceMap referenceMap, Object value, Object& result)
at Amazon.JSII.Runtime.CallbackExtensions.<>c__DisplayClass2_0.b__0(Int32 n)
at System.Linq.Enumerable.SelectRangeIterator1.ToArray() at System.Linq.Enumerable.ToArray[TSource](IEnumerable1 source)
at Amazon.JSII.Runtime.CallbackExtensions.InvokeMethod(InvokeRequest request, IReferenceMap referenceMap)
at Amazon.JSII.Runtime.CallbackExtensions.InvokeCallbackCore(Callback callback, IReferenceMap referenceMap)
at Amazon.JSII.Runtime.CallbackExtensions.InvokeCallback(Callback callback, IReferenceMap referenceMap, IFrameworkToJsiiConverter converter, String& error)
at Amazon.JSII.Runtime.Services.Client.TryDeserialize[TResponse](String responseJson)
at Amazon.JSII.Runtime.Services.Client.ReceiveResponseTResponse
at Amazon.JSII.Runtime.Services.Client.TryDeserialize[TResponse](String responseJson)
at Amazon.JSII.Runtime.Services.Client.ReceiveResponseTResponse
at Amazon.JSII.Runtime.Services.Client.Invoke(InvokeRequest request)
at Amazon.JSII.Runtime.Services.Client.Invoke(ObjectReference objectReference, String method, Object[] arguments)
at Amazon.JSII.Runtime.Deputy.DeputyBase.<>c__DisplayClass17_01.<InvokeInstanceMethod>b__1(IClient client, Object[] args) at Amazon.JSII.Runtime.Deputy.DeputyBase.<InvokeMethodCore>g__GetResult|18_0[T](<>c__DisplayClass18_01& )
at Amazon.JSII.Runtime.Deputy.DeputyBase.InvokeMethodCore[T](JsiiMethodAttribute methodAttribute, Object[] arguments, Func3 beginFunc, Func3 invokeFunc)
at Amazon.JSII.Runtime.Deputy.DeputyBase.InvokeInstanceMethod[T](Type[] parameterTypes, Object[] arguments, String methodName)
at Amazon.CDK.AWS.CodeCommit.Repository.OnCommit(String id, IOnCommitOptions options)
at Amazon.JSII.Runtime.Services.Client.TryDeserialize[TResponse](String responseJson)
at Amazon.JSII.Runtime.Services.Client.ReceiveResponseTResponse
at Amazon.JSII.Runtime.Services.Client.TryDeserialize[TResponse](String responseJson)
at Amazon.JSII.Runtime.Services.Client.ReceiveResponseTResponse
at Amazon.JSII.Runtime.Services.Client.Invoke(InvokeRequest request)
at Amazon.JSII.Runtime.Services.Client.Invoke(ObjectReference objectReference, String method, Object[] arguments)
at Amazon.JSII.Runtime.Deputy.DeputyBase.<>c__DisplayClass17_01.<InvokeInstanceMethod>b__1(IClient client, Object[] args) at Amazon.JSII.Runtime.Deputy.DeputyBase.<InvokeMethodCore>g__GetResult|18_0[T](<>c__DisplayClass18_01& )
at Amazon.JSII.Runtime.Deputy.DeputyBase.InvokeMethodCore[T](JsiiMethodAttribute methodAttribute, Object[] arguments, Func3 beginFunc, Func3 invokeFunc)
at Amazon.JSII.Runtime.Deputy.DeputyBase.InvokeInstanceMethod[T](Type[] parameterTypes, Object[] arguments, String methodName)
at Amazon.CDK.AWS.CodePipeline.Actions.CodeCommitSourceAction.Bound(Construct scope, IStage stage, IActionBindOptions options)
at Amazon.JSII.Runtime.Services.Client.TryDeserialize[TResponse](String responseJson)
at Amazon.JSII.Runtime.Services.Client.ReceiveResponseTResponse
at Amazon.JSII.Runtime.Services.Client.TryDeserialize[TResponse](String responseJson)
at Amazon.JSII.Runtime.Services.Client.ReceiveResponseTResponse
at Amazon.JSII.Runtime.Services.Client.Invoke(InvokeRequest request)
at Amazon.JSII.Runtime.Services.Client.Invoke(ObjectReference objectReference, String method, Object[] arguments)
at Amazon.JSII.Runtime.Deputy.DeputyBase.<>c__DisplayClass17_01.<InvokeInstanceMethod>b__1(IClient client, Object[] args) at Amazon.JSII.Runtime.Deputy.DeputyBase.<InvokeMethodCore>g__GetResult|18_0[T](<>c__DisplayClass18_01& )
at Amazon.JSII.Runtime.Deputy.DeputyBase.InvokeMethodCore[T](JsiiMethodAttribute methodAttribute, Object[] arguments, Func3 beginFunc, Func3 invokeFunc)
at Amazon.JSII.Runtime.Deputy.DeputyBase.InvokeInstanceMethod[T](Type[] parameterTypes, Object[] arguments, String methodName)
at Amazon.CDK.AWS.CodePipeline.Actions.Action.Bind(Construct scope, IStage stage, IActionBindOptions options)


This is 🐛 Bug Report

Metadata

Metadata

Assignees

Labels

bugThis issue is a bug.language/dotnetRelated to .NET bindingsneeds-triageThis issue or PR still needs to be triaged.p0

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions