-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
StepFunctions: Improvements to Timestamp Validation #12074
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
Conversation
LocalStack Community integration with Pro 2 files ± 0 2 suites ±0 34m 10s ⏱️ - 1h 16m 57s Results for commit a6f3688. ± Comparison against base commit 630b2a1. This pull request removes 2582 and adds 22 tests. Note that renamed tests count towards both.
This pull request removes 243 skipped tests and adds 5 skipped tests. Note that renamed tests count towards both.
♻️ This comment has been updated with latest results. |
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.
Great to see improved test coverage! 👍
.../localstack/services/stepfunctions/asl/component/state/state_wait/wait_function/timestamp.py
Outdated
Show resolved
Hide resolved
@@ -60,31 +72,34 @@ def _create_failure_event(self, env: Environment, timestamp_str: str) -> Failure | |||
event_details=EventDetails( | |||
executionFailedEventDetails=ExecutionFailedEventDetails( | |||
error=StatesErrorNameType.StatesRuntime.to_name(), | |||
cause=f"The TimestampPath parameter does not reference a valid ISO-8601 extended offset date-time format string: {self.string.literal_value} == {timestamp_str}", | |||
cause="The Timestamp parameter does not reference a valid ISO-8601 " | |||
f"extended offset date-time format string: {self.string.literal_value} == {timestamp_str}", |
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.
question: why do we need to print both literal value of object property and timestamp_str
parameter? Also, what ==
here means?
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.
This error message is composed in an effort to match AWS's error message in these circumstances (example).
The message lists how the expression provided for sampling the timestamp {self.string.literal_value}
evaluates to the invalid timestamp value {timestamp_str}
. The error message may look like this: The TimestampPath parameter does not reference a valid ISO-8601 extended offset date-time format string: $.TimestampValue == 2016-12-05 21:29:29Z"
Motivation
The Step Functions (SFN) v2 interpreter has certain limitations in validating timestamp strings for the Timestamp field. This field can be set statically using string literals or dynamically, such as via JSONata expressions. While validation exists for TimestampPath fields, similar logic was not applied to Timestamp fields. Consequently, some timestamps failed validation during state machine creation, as described in #11997.
These changes enhance the validation logic to ensure both statically provided and dynamically computed timestamp values are checked for proper format and a valid date. Additionally, a series of positive and negative test cases have been added to verify timestamp handling.
It is worth mentioning that dynamically computed invalid timestamps via JSONata expressions result in a generic execution failure rather than a new evaluation failure. This discrepancy is limited to the error type, while the failure description correctly conveys the issue. Improvements to this behaviour are planned as we introduce validation patterns for JSONata expression outcomes.
Changes
Timestamp*
fields