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

Step function Map throw error on synth #4417

Closed
apalumbo opened this issue Oct 8, 2019 · 11 comments
Closed

Step function Map throw error on synth #4417

apalumbo opened this issue Oct 8, 2019 · 11 comments
Assignees
Labels
@aws-cdk/aws-stepfunctions Related to AWS StepFunctions bug This issue is a bug. in-progress This issue is being actively worked on.

Comments

@apalumbo
Copy link
Contributor

apalumbo commented Oct 8, 2019

The current implementation of the Map state in step function has an issue in the validate(), when you try to synth a stack you always get that the iterator is not provided.

Reproduction Steps

I've created a PR that adds a unit test and fixes the problem #4382

packages/@aws-cdk/aws-stepfunctions/test/test.map.ts

Error Log

"Map state must have a non-empty iterator"


This is 🐛 Bug Report

@apalumbo apalumbo added bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels Oct 8, 2019
@NGL321 NGL321 added @aws-cdk/aws-stepfunctions Related to AWS StepFunctions in-progress This issue is being actively worked on. and removed needs-triage This issue or PR still needs to be triaged. labels Oct 8, 2019
@oleksii-donoha
Copy link

As a temporary workaround I use CfnStateMachine and render definition string manually (using Jinja2 for example)

@jeshan
Copy link

jeshan commented Oct 14, 2019

I don't understand. Since iterator is required in Map and adding iterator does not work, then how were we supposed to use it?

@apalumbo
Copy link
Contributor Author

@jeshan It is just a bug, when the #4382 will be merged and released we could use the Map feature

@jeshan
Copy link

jeshan commented Oct 14, 2019

Right! That's why I'm wondering: was it ever usable in 1.12?

@apalumbo
Copy link
Contributor Author

apalumbo commented Oct 14, 2019

no, hoping that PR will be merged before 1.13

@ChintanRaval
Copy link
Contributor

same issues faced here.. hoping the PR gets landed soon 🤞

@rix0rrr
Copy link
Contributor

rix0rrr commented Oct 22, 2019

Closed by linked PR

@rix0rrr rix0rrr closed this as completed Oct 22, 2019
@yyolk
Copy link

yyolk commented Oct 23, 2019

I'm still facing this issue with the latest cdk release, creating my stack in python with something like:

from aws_cdk import (
    core,
    aws_stepfunctions as sfn,
)
class MyTestStack(core.Stack)

    def __init__(self, parent, id_, props):
           super().__init__(app, id_)
           pass_map = sfn.Pass(self, "Map Iterator Pass")
           poly_to_tiles_task_map = sfn.Map(
               self,
               "Polygong2TilesMap",
               max_concurrency=0,
           )

           poly_to_tiles_task_map.iterator(pass_map)
           ....

but upon a synth I receive the error:

jsii.errors.JSIIError: Validation failed with the following errors:
  [yolk-test-stack-large-parcel/Polygong2TilesMap] Map state must have a non-empty iterator

@jeshan
Copy link

jeshan commented Oct 23, 2019

You need to declare an iterator. Here is an example in JavaScript syntax:

let mapState = new Map(this, 'map', {
            itemsPath: '$.somePath', // probably optional
})
.iterator({
  startState: yourStartTask,
})
.next(someOtherTask);

@yyolk
Copy link

yyolk commented Oct 23, 2019

@jeshan thank you very much. I've tried passing in a dict to the iterator() using the colloquial keys for python - this is what it looks like:

class MyTestStack(core.Stack)

    def __init__(self, parent, id_, props):
           super().__init__(app, id_)
           pass_map = sfn.Pass(self, "Map Iterator Pass")
           poly_to_tiles_task_map = sfn.Map(
               self,
               "Polygong2TilesMap",
               max_concurrency=0,
           )
           poly_to_tiles_task_map.iterator({"start_state": pass_map})
           ...

I then receive this error:

jsii.errors.JSIIError: Expected object reference, got {"start_state":{"$jsii.byref":"@aws-cdk/aws-stepfunctions.Pass@10047"}}
/private/var/folders/th/2gznbq494d1gxbnbj1215ccc0000gn/T/jsii-kernel-5xp9xO/node_modules/@aws-cdk/core/lib/construct.js:58
                throw new Error(`Validation failed with the following errors:\n  ${errorList}`);
                ^

Error: Validation failed with the following errors:
  [yolk-test-stack-large-parcel] Map state must have a non-empty iterator

stepfunctions.Pass implements IChainable and should be able to be passed directly like in the test case here: https://github.com/apalumbo/aws-cdk/blob/d67ec09fd0345a821b799c9cb24728d49c5d6b2b/packages/%40aws-cdk/aws-stepfunctions/test/test.map.ts#L47-L59

Any other pointers would be appreciated! edit: and it does, see this comment

@yyolk
Copy link

yyolk commented Oct 23, 2019

I fiddled around with it some more, and discovered that I must chain the .iterator() when I instantiate the Map() like you described @jeshan . This worked enough to synth a template:

pass_map = sfn.Pass(self, "Map Iterator Pass")
poly_to_tiles_task_map = sfn.Map(
    self,
    "Polygong2TilesMap",
    max_concurrency=0,
).iterator(pass_map)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
@aws-cdk/aws-stepfunctions Related to AWS StepFunctions bug This issue is a bug. in-progress This issue is being actively worked on.
Projects
None yet
Development

No branches or pull requests

7 participants