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

Implemented interface discovery broken in Python as well #2963

Closed
1 of 5 tasks
rix0rrr opened this issue Aug 19, 2021 · 1 comment · Fixed by #2964
Closed
1 of 5 tasks

Implemented interface discovery broken in Python as well #2963

rix0rrr opened this issue Aug 19, 2021 · 1 comment · Fixed by #2964
Assignees
Labels
bug This issue is a bug. language/python Related to Python bindings module/pacmak Issues affecting the `jsii-pacmak` module module/runtime Issues affecting the `jsii-runtime` p1

Comments

@rix0rrr
Copy link
Contributor

rix0rrr commented Aug 19, 2021

🐛 Bug Report

I have another one similar to #2951

Originally reported as aws/aws-cdk#16120

Affected Languages

  • TypeScript or Javascript
  • Python
  • Java
  • .NET (C#, F#, ...)
  • Go

What is the problem?

Python code:

 
@jsii.implements(pipelines.ICodePipelineActionFactory)
class SomeStep(pipelines.Step):
    def __init__(self, id_):
        super().__init__(id_)
 
    @jsii.member(jsii_name="produceAction")
    def produce_action(
            self, stage: aws_codepipeline.IStage,
            options: pipelines.ProduceActionOptions,
            # TODO why are these not passed?
            # *,
            # action_name, artifacts, pipeline, run_order, scope,
            # before_self_mutation=None,
            # code_build_defaults=None,
            # fallback_artifact=None
    ) -> pipelines.CodePipelineActionFactoryResult:
        stage.add_action(
            aws_codepipeline_actions.StepFunctionInvokeAction(
                state_machine=aws_stepfunctions.StateMachine.from_state_machine_arn("..."),
                action_name="foo",
                state_machine_input=aws_codepipeline_actions.StateMachineInput.literal({"foo": "bar"}),
                run_order=options["run_order"],
            )
        )
 
        return pipelines.CodePipelineActionFactoryResult(run_orders_consumed=1)

When used in a Pipelines pipeline, leads to the following error:

jsii.errors.JavaScriptError: 
  Error: '' object has no attribute 'add_action'
      at KernelHost.completeCallback (/private/var/folders/ln/r1dlp_xj6t57ddclvh7zgl8m0000gp/T/tmpwwmvzicu/lib/program.js:9462:35)
      at KernelHost.callbackHandler (/private/var/folders/ln/r1dlp_xj6t57ddclvh7zgl8m0000gp/T/tmpwwmvzicu/lib/program.js:9453:41)
      at Step.value (/private/var/folders/ln/r1dlp_xj6t57ddclvh7zgl8m0000gp/T/tmpwwmvzicu/lib/program.js:8323:49)
      at CodePipeline.pipelineStagesAndActionsFromGraph (/private/var/folders/ln/r1dlp_xj6t57ddclvh7zgl8m0000gp/T/jsii-kernel-x3iY7A/node_modules/@aws-cdk/pipelines/lib/codepipeline/codepipeline.js:154:48)
      at CodePipeline.doBuildPipeline (/private/var/folders/ln/r1dlp_xj6t57ddclvh7zgl8m0000gp/T/jsii-kernel-x3iY7A/node_modules/@aws-cdk/pipelines/lib/codepipeline/codepipeline.js:116:14)
      at CodePipeline.buildPipeline (/private/var/folders/ln/r1dlp_xj6t57ddclvh7zgl8m0000gp/T/jsii-kernel-x3iY7A/node_modules/@aws-cdk/pipelines/lib/main/pipeline-base.js:93:14)
      at CodePipeline.buildJustInTime (/private/var/folders/ln/r1dlp_xj6t57ddclvh7zgl8m0000gp/T/jsii-kernel-x3iY7A/node_modules/@aws-cdk/pipelines/lib/main/pipeline-base.js:101:18)
      at Object.visit (/private/var/folders/ln/r1dlp_xj6t57ddclvh7zgl8m0000gp/T/jsii-kernel-x3iY7A/node_modules/@aws-cdk/pipelines/lib/main/pipeline-base.js:42:57)
      at recurse (/private/var/folders/ln/r1dlp_xj6t57ddclvh7zgl8m0000gp/T/jsii-kernel-x3iY7A/node_modules/@aws-cdk/core/lib/private/synthesis.js:86:20)
      at recurse (/private/var/folders/ln/r1dlp_xj6t57ddclvh7zgl8m0000gp/T/jsii-kernel-x3iY7A/node_modules/@aws-cdk/core/lib/private/synthesis.js:98:17)

The produce_action call takes a struct that contains an IStage, which has an addAction() method. The method is not translated to add_action, probably because the interfaces aren't discovered properly again:

> {
  "fqn": "@aws-cdk/pipelines.Step",
  "args": [
    "some"
  ],
  "overrides": [
    {
      "method": "produceAction",
      "property": null,
      "cookie": "produce_action"
    }
  ],
  "interfaces": [
    "@aws-cdk/pipelines.IFileSetProducer" // <-- missing ICodePipelineActionFactory here
  ],
  "api": "create"

Repro here: https://github.com/rix0rrr/jsii-repro

@rix0rrr rix0rrr added bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels Aug 19, 2021
RomainMuller added a commit that referenced this issue Aug 19, 2021
When a type extends a jsii class, any additional interfaces implemented
via the `@jsii.implements` annotation were not properly registered, and
overrides were not properly discovered.

This was the combination of a code-generation bug, which caused the type
passed to the `create` kernel method to be that of the jsii class,
instead of the dynamic class (`self.__class__`); and a kernel bug, which
caused those inheritance graphs to completely skip overrides detection.

Fixes #2963
RomainMuller added a commit that referenced this issue Aug 19, 2021
When a type extends a jsii class, any additional interfaces implemented
via the `@jsii.implements` annotation were not properly registered, and
overrides were not properly discovered.

This was the combination of a code-generation bug, which caused the type
passed to the `create` kernel method to be that of the jsii class,
instead of the dynamic class (`self.__class__`); and a kernel bug, which
caused those inheritance graphs to completely skip overrides detection.

Fixes #2963
@RomainMuller RomainMuller added language/python Related to Python bindings module/pacmak Issues affecting the `jsii-pacmak` module module/runtime Issues affecting the `jsii-runtime` p1 bug This issue is a bug. and removed bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels Aug 19, 2021
@RomainMuller RomainMuller self-assigned this Aug 19, 2021
@mergify mergify bot closed this as completed in #2964 Aug 19, 2021
mergify bot pushed a commit that referenced this issue Aug 19, 2021
When a type extends a jsii class, any additional interfaces implemented
via the `@jsii.implements` annotation were not properly registered, and
overrides were not properly discovered.

This was the combination of a code-generation bug, which caused the type
passed to the `create` kernel method to be that of the jsii class,
instead of the dynamic class (`self.__class__`); and a kernel bug, which
caused those inheritance graphs to completely skip overrides detection.

Fixes #2963



---

By submitting this pull request, I confirm that my contribution is made under the terms of the [Apache 2.0 license].

[Apache 2.0 license]: https://www.apache.org/licenses/LICENSE-2.0
@github-actions
Copy link
Contributor

⚠️COMMENT VISIBILITY WARNING⚠️

Comments on closed issues are hard for our team to see.
If you need more assistance, please either tag a team member or open a new issue that references this one.
If you wish to keep having a conversation with other community members under this issue feel free to do so.

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/python Related to Python bindings module/pacmak Issues affecting the `jsii-pacmak` module module/runtime Issues affecting the `jsii-runtime` p1
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants