Skip to content

refactor(stepfunctions): extract apply_state_catcher helper#332

Merged
vieiralucas merged 1 commit intomainfrom
worktree-cleanup+stepfn-splits
Apr 13, 2026
Merged

refactor(stepfunctions): extract apply_state_catcher helper#332
vieiralucas merged 1 commit intomainfrom
worktree-cleanup+stepfn-splits

Conversation

@vieiralucas
Copy link
Copy Markdown
Member

@vieiralucas vieiralucas commented Apr 13, 2026

Summary

The fallible states in `run_states` (`Task`, `Parallel`, `Map`) each had the same 18-line block for handling an execution error: read the `Catch` array off the state def, ask `find_catcher` for a matching clause, build an `Error`/`Cause` JSON, run `apply_result_path`, and advance to the chosen next state — or propagate the error if no clause matched.

Move that into `apply_state_catcher`, returning `Option<(next_state, new_effective_input)>`. The three call sites shrink from ~15 lines each to a 7-line match. Behaviour unchanged.

Test plan

  • `cargo fmt`
  • `cargo clippy --workspace --all-targets -- -D warnings`
  • `cargo test -p fakecloud-stepfunctions` (43 passed)

Summary by cubic

Extracted apply_state_catcher to centralize Catch handling for Task, Parallel, and Map states in the Step Functions interpreter. This removes duplicate error-handling blocks, simplifies run_states, and keeps behavior unchanged (returns Option<(next_state, new_effective_input)>).

Written for commit 0075587. Summary will update on new commits.

The fallible states in run_states (Task, Parallel, Map) each had the
same 18-line block for handling an execution error: read the Catch
array off the state def, ask find_catcher for a matching clause,
build an Error/Cause JSON, run apply_result_path, and advance to the
chosen next state — or propagate the error if no clause matched.

Move that into apply_state_catcher, returning
Option<(next_state, new_effective_input)>. The three call sites shrink
from ~15 lines each to a 7-line match. Behaviour unchanged.
Copy link
Copy Markdown

@cubic-dev-ai cubic-dev-ai Bot left a comment

Choose a reason for hiding this comment

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

No issues found across 1 file

@vieiralucas vieiralucas merged commit ceb5179 into main Apr 13, 2026
22 checks passed
@vieiralucas vieiralucas deleted the worktree-cleanup+stepfn-splits branch April 13, 2026 02:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant