-
Notifications
You must be signed in to change notification settings - Fork 4k
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
fix(stepfunctions): item batcher doesn't properly render json paths #29152
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The pull request linter has failed. See the aws-cdk-automation comment below for failure reasons. If you believe this pull request should receive an exemption, please comment and provide a justification.
A comment requesting an exemption should contain the text Exemption Request
. Additionally, if clarification is needed add Clarification Request
to a comment.
e96a4cd
to
85d4433
Compare
✅ Updated pull request passes all PRLinter validations. Dismissing previous PRLinter review.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me 👍
Can you please update the title to describe the bug (not the solution)?
Done! Thanks for the review! |
e951272
to
03ec32f
Compare
Rebased on main and amended the commit message. |
@noseworthy Thank you for this contribution. But I would like to get more context on the issue we are trying to solve.
|
@@ -631,6 +634,9 @@ describe('Distributed Map State', () => { | |||
ToleratedFailurePercentagePath: '$.toleratedFailurePercentage', | |||
ToleratedFailureCountPath: '$.toleratedFailureCount', | |||
ItemBatcher: { | |||
BatchInput: { | |||
'TestBatchInput.$': '$.testBatchInput', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you provide detail on why we need to expect '.$'
to the key?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 to this, a brief comment here explaining why we need the .$
and what it signifies (likely with a link to the relevant docs) would be very helpful
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can do! It might be a little while for a proper response. I'm away for the next week, but will try to get to it when I get back.
The long and short of it is that stepfunctions will parse keys that end in .$ as json paths and will look up the value from previous states using the value of this key rather than just passing the value to the next state.
This is done in almost all other state configuration so that values can be dynamically included from previous states, but this functionality was missed here requiring the user to manually specify '.$'. This is confusing and it isn't clear that the json paths aren't automatically rendered by the cdk construct parsing.
See documentation here: https://docs.aws.amazon.com/step-functions/latest/dg/connect-parameters.html#connect-parameters-path
And here: https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_stepfunctions.JsonPath.html
@@ -71,7 +73,7 @@ export class ItemBatcher { | |||
...(this.props.maxItemsPerBatchPath && { MaxItemsPerBatchPath: this.props.maxItemsPerBatchPath }), | |||
...(this.props.maxInputBytesPerBatch && { MaxInputBytesPerBatch: this.props.maxInputBytesPerBatch }), | |||
...(this.props.maxInputBytesPerBatchPath && { MaxInputBytesPerBatchPath: this.props.maxInputBytesPerBatchPath }), | |||
...(this.props.batchInput && { BatchInput: this.props.batchInput }), | |||
...(this.props.batchInput && { BatchInput: FieldUtils.renderObject(this.props.batchInput) }), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would suggest to update the PR description with detail specifically for batchInput
property in the itemBatcher class. To me from the description its not clear specifcally to which property we are modifying.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would like to understand more on why do we need to render only this specifc batchInput
property since the existing behavious itself will be able to pass Json payload to the batchInput
property?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1 to the question above and also to provide some more details in the description.
1b75865
to
5954dd8
Compare
5954dd8
to
2b99080
Compare
The ItemBatcher property of DistributedMap supports json path fields, but the new DistributedMap construct doesn't call FieldUtils.renderObject when rendering the ItemBatcher. Make sure to call `FieldUtils.renderObject()` when rendering this property. Added an integration test to ensure that the json path field resolves to the actual value from the state in the input by checking the output from the results writer in S3.
2b99080
to
27fff5d
Compare
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @noseworthy, just wondering if you're still available to work on this. Theres just the one pending question + an integ test snapshot that needs to be updated. Thanks!
@@ -71,7 +73,7 @@ export class ItemBatcher { | |||
...(this.props.maxItemsPerBatchPath && { MaxItemsPerBatchPath: this.props.maxItemsPerBatchPath }), | |||
...(this.props.maxInputBytesPerBatch && { MaxInputBytesPerBatch: this.props.maxInputBytesPerBatch }), | |||
...(this.props.maxInputBytesPerBatchPath && { MaxInputBytesPerBatchPath: this.props.maxInputBytesPerBatchPath }), | |||
...(this.props.batchInput && { BatchInput: this.props.batchInput }), | |||
...(this.props.batchInput && { BatchInput: FieldUtils.renderObject(this.props.batchInput) }), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1 to the question above and also to provide some more details in the description.
Sorry @paulhcsun, I've been swamped and haven't been able to get back to this yet. |
No worries @noseworthy, just wanted to confirm this PR was not abandoned. Though with our automation this will be closed after 3 weeks due to the Changes Requested status. |
This PR has been in the CHANGES REQUESTED state for 3 weeks, and looks abandoned. To keep this PR from being closed, please continue work on it. If not, it will automatically be closed in a week. |
This PR has been deemed to be abandoned, and will be automatically closed. Please create a new PR for these changes if you think this decision has been made in error. |
Comments on closed issues and PRs are hard for our team to see. |
Reason for this change
The ItemBatcher property of DistributedMap supports json path fields, but the new DistributedMap construct doesn't call
FieldUtils.renderObject when rendering the ItemBatcher.
Description of changes
Make sure to call
FieldUtils.renderObject()
when rendering this property.Description of how you validated changes
Checklist
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license