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

bug: JsonPathParserError in TimestampPath when any path fragments begin with a number #10694

Open
1 task done
attila opened this issue Apr 19, 2024 · 2 comments
Open
1 task done
Assignees
Labels
aws:stepfunctions AWS Step Functions status: backlog Triaged but not yet being worked on type: bug Bug report

Comments

@attila
Copy link

attila commented Apr 19, 2024

Is there an existing issue for this?

  • I have searched the existing issues

Current Behavior

Hi again,

It looks like the path parser cannot parse JSON inputs when any path fragments begin with a number.

Given the stepfunction example below, starting an execution gives the following error:

localstack  | 2024-04-19T08:41:44.527  INFO --- [   asgi_gw_0] localstack.request.aws     : AWS stepfunctions.StartExecution => 200
localstack  | 2024-04-19T08:41:44.550 ERROR --- [ad-10 (eval)] l.s.s.a.c.eval_component   : Exception=JsonPathParserError, Details=['Parse error at 1:3 near token DayBeforeTimeStamp (ID)'] at '(TimestampPath| {'path': '$.1DayBeforeTimeStamp'}'
localstack  | 2024-04-19T08:41:44.551 ERROR --- [ad-10 (eval)] l.s.s.a.c.eval_component   : Exception=JsonPathParserError, Details=['Parse error at 1:3 near token DayBeforeTimeStamp (ID)'] at '(StateWait| {'comment': None, 'input_path': (InputPath| {'input_path_src': '$'}, 'output_path': (OutputPath| {'output_path': '$'}, 'state_entered_event_type': 'WaitStateEntered', 'state_exited_event_type': 'WaitStateExited', 'name': 'WaitFor1DayBefore', 'state_type': <StateType.Wait: 21>, 'continue_with': <localstack.services.stepfunctions.asl.component.state.state_continue_with.ContinueWithNext object at 0x7fcda9295c10>, 'wait_function': (TimestampPath| {'path': '$.1DayBeforeTimeStamp'}}'
localstack  | 2024-04-19T08:41:44.551 ERROR --- [ad-10 (eval)] l.s.s.a.c.program.program  : Stepfunctions computation ended with exception 'JsonPathParserError(Parse error at 1:3 near token DayBeforeTimeStamp (ID))'.

Expected Behavior

JSON path fragments that begin with numbers are still treated as strings and path traversal works as expected, just like in the production AWS service or in AWS' own stepfunctions-local.

How are you starting LocalStack?

With a docker-compose file

Steps To Reproduce

How are you starting localstack (e.g., bin/localstack command, arguments, or docker-compose.yml)

docker compose up

Client commands (e.g., AWS SDK code snippet, or sequence of "awslocal" commands)

awslocal stepfunctions create-state-machine --name 'example' --role-arn "arn:aws:iam::000000000000:role/stepfunctions-role" --definition '{"StartAt":"WaitFor1DayBefore","States":{"WaitFor1DayBefore":{"Type": "Wait","TimestampPath":"$.1DayBeforeTimeStamp","Next":"1DayBefore"},"1DayBefore":{"Type":"Pass","End":true}}}'

awslocal stepfunctions start-execution --state-machine-arn 'arn:aws:states:eu-west-1:000000000000:stateMachine:example' --input '{"1DayBeforeTimeStamp":"2024-04-21T12:34:56Z"}'

I inlined the definition in the example but here it is for better readability:

{
  "StartAt": "WaitFor1DayBefore",
  "States": {
    "WaitFor1DayBefore": {
      "Type": "Wait",
      "TimestampPath": "$.1DayBeforeTimeStamp",
      "Next": "1DayBefore"
    },
    "1DayBefore": {
      "Type": "Pass",
      "End": true
    }
  }
}

Input specified:

{
  "1DayBeforeTimestamp": "2024-04-21T12:34:56Z"
}

Environment

- OS: MacOS 14
- LocalStack: 3.3.0

Anything else?

No response

@attila attila added status: triage needed Requires evaluation by maintainers type: bug Bug report labels Apr 19, 2024
@cloutierMat cloutierMat added aws:stepfunctions AWS Step Functions status: backlog Triaged but not yet being worked on and removed status: triage needed Requires evaluation by maintainers labels Apr 19, 2024
@MEPalma MEPalma self-assigned this Apr 21, 2024
@TheDanGior
Copy link

I am seeing a similar bug when my JSON path starts with a symbol. The @class JSON path is included automatically by our library when serializing to JSON from Java.

Input:

{
    "@class":"com.company.name.InputData",
    "id":"123abc",
    "sourceUserId":"101",
    "inputFileS3Keys": [ "00000000-1111-2222-3333-444444444" ]
}

Error:

Exception=JsonPathParserError, Details=['Parse error at 1:1 near token $ ($)'] at '(StatePass| {'comment': None, 'input_path': (InputPath| {'input_path_src': '$$.Execution.Id'}, 'output_path': (OutputPath| {'output_path': '$'}, 'state_entered_event_type': 'PassStateEntered', 'state_exited_event_type': 'PassStateExited', 'result': None, 'result_path': (ResultPath| {'result_path_src': '$.id'}, 'parameters': None, 'name': 'EmbedId', 'state_type': <StateType.Pass: 20>, 'continue_with': <localstack.services.stepfunctions.asl.component.state.state_continue_with.ContinueWithNext object at 0x7f0820510550>}'

@MEPalma
Copy link
Contributor

MEPalma commented May 13, 2024

Thank you for compiling this bug report! The issue appears to be related to some limitations to the JsonPath library that the StepFunctions interpreter relies on https://github.com/h2non/jsonpath-ng.
These are issues related to the same issue: #10603, #9937 (comment).
Nevertheless, we are looking into this limitation and I will be happy to update you as soon as a solution is implemented.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
aws:stepfunctions AWS Step Functions status: backlog Triaged but not yet being worked on type: bug Bug report
Projects
None yet
Development

No branches or pull requests

4 participants