Skip to content
This repository was archived by the owner on Mar 23, 2026. It is now read-only.

[SFN] [TestState] Add support for PRESENT and NONE field validation modes. - #13422

Merged
tiurin merged 5 commits into
feature/step-functions/test-state-field-validation-mode-strictfrom
feature/step-functions/test-state-field-validation-mode-present
Nov 28, 2025
Merged

tiurin merged 5 commits into
feature/step-functions/test-state-field-validation-mode-strictfrom
feature/step-functions/test-state-field-validation-mode-present

Conversation

@tiurin

@tiurin tiurin commented Nov 26, 2025

Copy link
Copy Markdown
Contributor

Motivation

Add support for 2 remaining field validation modes.

Companion PR to #13419 .

Closes DRG-221.

Changes

  • PRESENT field validation mode doesn't check the presence of required fields. It only validates the type and format of the fields that are present in the user-provided mock
  • NONE mode means no format validation will be performed. A check that the result is a valid JSON string is still performed even in NONE field validation mode.

Also switches validation to use mock_input directly as TestStateMock is an overkill in this validation context.

Tests

Related

@tiurin
tiurin requested a review from gregfurman November 26, 2025 16:45
@tiurin tiurin added aws:stepfunctions AWS Step Functions semver: minor Non-breaking changes which can be included in minor releases, but not in patch releases docs: skip Pull request does not require documentation changes notes: skip Pull request does not have to be mentioned in the release notes labels Nov 26, 2025
@tiurin tiurin added this to the 4.12 milestone Nov 26, 2025
@github-actions

github-actions Bot commented Nov 26, 2025

Copy link
Copy Markdown

Test Results - Preflight, Unit

22 669 tests  ±0   20 901 ✅ ±0   6m 20s ⏱️ -1s
     1 suites ±0    1 768 💤 ±0 
     1 files   ±0        0 ❌ ±0 

Results for commit 625b59a. ± Comparison against base commit 08d99fe2.

♻️ This comment has been updated with latest results.

@github-actions

github-actions Bot commented Nov 26, 2025

Copy link
Copy Markdown

LocalStack Community integration with Pro

    2 files  ± 0      2 suites  ±0   21m 34s ⏱️ +11s
1 686 tests +20  1 603 ✅ +16  83 💤 +4  0 ❌ ±0 
1 688 runs  +20  1 603 ✅ +16  85 💤 +4  0 ❌ ±0 

Results for commit 625b59a. ± Comparison against base commit 08d99fe2.

♻️ This comment has been updated with latest results.

@github-actions

github-actions Bot commented Nov 26, 2025

Copy link
Copy Markdown

Test Results (amd64) - Acceptance

7 tests  ±0   5 ✅ ±0   3m 21s ⏱️ -1s
1 suites ±0   2 💤 ±0 
1 files   ±0   0 ❌ ±0 

Results for commit 625b59a. ± Comparison against base commit 08d99fe2.

♻️ This comment has been updated with latest results.

@github-actions

github-actions Bot commented Nov 26, 2025

Copy link
Copy Markdown

Test Results (amd64) - Integration, Bootstrap

    5 files  ± 0      5 suites  ±0   38m 53s ⏱️ -11s
1 710 tests +20  1 628 ✅ +16  82 💤 +4  0 ❌ ±0 
1 716 runs  +20  1 628 ✅ +16  88 💤 +4  0 ❌ ±0 

Results for commit 625b59a. ± Comparison against base commit 08d99fe2.

♻️ This comment has been updated with latest results.

@tiurin
tiurin force-pushed the feature/step-functions/test-state-field-validation-mode-strict branch from 957a2e0 to 08d99fe Compare November 27, 2025 11:35
@tiurin
tiurin requested a review from steffyP as a code owner November 27, 2025 11:35
@tiurin
tiurin force-pushed the feature/step-functions/test-state-field-validation-mode-present branch from c8a3600 to 625b59a Compare November 27, 2025 11:36
@tiurin tiurin self-assigned this Nov 27, 2025

@staticmethod
def validate_mock(mock: TestStateMock, definition: Definition, state_name: StateName) -> None:
def validate_mock(mock_input: MockInput, definition: Definition, state_name: StateName) -> None:

@gregfurman gregfurman Nov 27, 2025

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

question: What happens if we don't define an errorOuput correctly? Pretty sure that needs to have the proper fields as well i.e Error and Cause. Could be worthwhile leaving the TestStateMock and doing that check here as well?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's worth separating 2 validations: one is result field validation against API shape, that is being done here, another is the rest of mock input. I guess the function name is misleading, I will rename it to a more specific validate_mock_result_input.

What you say about missing error output validation totally makes sense, I think we need to do in an upcoming PR, wdyt? And consolidate all validations that are not result shape ones in one place - now several of them are scattered around different methods. I also think it can be done on MockInput directly - TestStateMock at this stage is a bit of overkill at this stage, I tried it and it only causes creating more data access methods.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah let's address in a follow-up. I think seperating out the validations into result, errorOutput,stateConfiguration, and context.

Maybe we attach these validations as static methods to the TestStateMock?

@tiurin
tiurin requested a review from gregfurman November 27, 2025 17:25
@tiurin
tiurin merged commit 48462aa into feature/step-functions/test-state-field-validation-mode-strict Nov 28, 2025
40 checks passed
@tiurin
tiurin deleted the feature/step-functions/test-state-field-validation-mode-present branch November 28, 2025 11:52
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

aws:stepfunctions AWS Step Functions docs: skip Pull request does not require documentation changes notes: skip Pull request does not have to be mentioned in the release notes semver: minor Non-breaking changes which can be included in minor releases, but not in patch releases

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants