fix: handle CloudFormation intrinsic functions in Arguments.StateMachineArn#709
Merged
zirkelc merged 1 commit intoserverless-operations:masterfrom Mar 23, 2026
Conversation
…ineArn
When using JSONata QueryLanguage with a CloudFormation intrinsic function
(e.g. !Sub or Fn::Sub) as StateMachineArn in Arguments, getStateMachineArn()
calls .trim() on the value expecting a string, but intrinsic functions resolve
to objects like {"Fn::Sub": "..."}, causing:
TypeError: state.Arguments.StateMachineArn.trim is not a function
Check if StateMachineArn is a string before calling .trim(). When it is an
object (CloudFormation intrinsic), return it as-is for use in the IAM policy
resource, matching the existing behavior for Parameters.StateMachineArn.
Made-with: Cursor
kevinzhang-alayacare
approved these changes
Mar 20, 2026
commit: |
zirkelc
approved these changes
Mar 23, 2026
This was referenced Mar 23, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #704
Summary
QueryLanguagewith a CloudFormation intrinsic function (e.g.!SuborFn::Sub) asStateMachineArninArguments,getStateMachineArn()crashes withTypeError: state.Arguments.StateMachineArn.trim is not a functionbecause it assumes the value is a string, but intrinsic functions resolve to objects like{"Fn::Sub": "..."}..trim()— whenStateMachineArnis not a string (i.e. a CloudFormation intrinsic), return it as-is for use in the IAM policy resource. This matches the existing behavior forParameters.StateMachineArnwhich already handles intrinsics correctly.Reproduction
Changes
lib/deploy/stepFunctions/compileIamRole.js: Checktypeof arn !== 'string'before calling.trim()ingetStateMachineArn()lib/deploy/stepFunctions/compileIamRole.test.js: Added test case for JSONata with CloudFormation intrinsicStateMachineArnTest plan
Fn::Subobject is passed through correctly as the IAM policy resource