Skip to content

State machine definition does not support JSONata #637

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Open
villagoizi opened this issue Dec 12, 2024 · 5 comments
Open

State machine definition does not support JSONata #637

villagoizi opened this issue Dec 12, 2024 · 5 comments

Comments

@villagoizi
Copy link

Does not support JSONata

Description
In this line of code it expects a state.Parameters but when you use JSONata everything changes from Parameters to Arguments.

const functionName = state.Parameters.FunctionName;

You get the following exception when performing an sls deploy:
TypeError: Cannot read properties of undefined (reading 'FunctionName')

This is the definition used

Comment: Validate
StartAt: input validation
QueryLanguage: JSONata
States:
  input validation:
    Type: Task
    Resource: arn:aws:states:::lambda:invoke
    Output: '{% $states.result.Payload %}'
    Assign:
      command: '{% $merge([$states.input.params.path, $states.input.body]) %}'
      meta: '{% $states.input %}'
    Arguments:
      FunctionName:
        'Fn::GetAtt':
          - ValidatorLambda
          - Arn
      Payload:
        rule: ${file(src/model-config/schemas/update.yml)}
        payload: '{% $merge([$states.input.params.path, $states.input.body]) %}'
    Retry:
      - ErrorEquals:
          - States.ALL
        IntervalSeconds: 1
        MaxAttempts: 2
        BackoffRate: 1
        JitterStrategy: FULL
    End: true

Additional data

  • Serverless Framework Core Version you're using: ^3
  • The Plugin Version you're using: ^3.21.1
  • Operating System: Linux
@villagoizi villagoizi changed the title State machine does not support JSONata State machine definition does not support JSONata Dec 12, 2024
@olivierto
Copy link

  • 1 same issue !
    Converted a big step function to JSONata in the AWS console... lost 2 days of work to realise that it's not supported :'(
    I will try to make a PR ...

@zirkelc
Copy link
Contributor

zirkelc commented Mar 24, 2025

@villagoizi I have implemented JSONata support in PR #636

It looks like it wasn't released yet, but you can use my preview branch: https://pkg.pr.new/zirkelc/serverless-step-functions@d2555b7

@horike37 when will you release a new version?

@edvaldoszy
Copy link

Hi everyone!

I created a PR adding support for Lambda: #645

@gson88
Copy link

gson88 commented Apr 7, 2025

Hmm I use JSONata in step functions without issues so far, am I using it wrong?
What is the purpose of making the resource arn:aws:states:::lambda:invoke instead of the lambda I want to invoke?

StartAt: CloneStuff
QueryLanguage: "JSONata"
States:
  CloneStuff:
    Type: Task
    Resource:
      Fn::GetAtt: [ function, Arn ]
    Assign:
      fromNodeId: "{% $states.input.projectId %}"
      toNodeId: "{% $states.result.nodeId %}"
      author: "{% $states.input.author %}"
    Next: CopySomeTypes
  CopySomeTypes:
    Type: Task
    Resource: resourceArn
    Arguments:
      author: "{% $author %}"
      fromNodeId: "{% $fromNodeId %}"
      toNodeId: "{% $toNodeId %}"
    Output:
      output:
        someType: "{% $states.result.body %}"
    End: true

@zirkelc
Copy link
Contributor

zirkelc commented Apr 7, 2025

@gson88 arn:aws:states:::lambda:invoke is called an optimized integration: https://docs.aws.amazon.com/step-functions/latest/dg/connect-lambda.html

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants