Skip to content

fix: preserve custom error handler continuations#366

Open
hjotha wants to merge 3 commits intomendixlabs:mainfrom
hjotha:submit/custom-error-handler-routing
Open

fix: preserve custom error handler continuations#366
hjotha wants to merge 3 commits intomendixlabs:mainfrom
hjotha:submit/custom-error-handler-routing

Conversation

@hjotha
Copy link
Copy Markdown
Contributor

@hjotha hjotha commented Apr 27, 2026

Closes #349.
Part of #332.

Summary

  • keeps custom error-handler paths pending until the next safe continuation is known
  • rejoins non-terminal handler bodies through a merge instead of fabricating detached EndEvents
  • preserves empty custom-handler error flows and prevents output-producing error paths from continuing into statements that read a missing output variable

Validation

  • make build
  • make lint-go
  • make test

Symptom: custom error-handler bodies that did not explicitly return were rebuilt as detached terminal paths, while empty custom handlers could either lose their error flow or rejoin into statements that read an output variable that is absent on the error path.

Root cause: the microflow builder handled custom error handlers immediately at the source activity. It did not retain pending handler state until the next safe continuation was known, and a later handler could overwrite an earlier pending handler.

Fix: queue pending custom handler state, route non-terminal handlers through the next safe continuation via a merge, preserve empty custom-handler flows, and terminate output-producing handlers before output-dependent continuation statements in void microflows.

Tests: added synthetic builder regressions for non-terminal handler rejoin, consecutive pending handlers, empty output-handler termination, and empty no-output-handler rejoin. Ran make build, make lint-go, and make test.
hjothamendix and others added 2 commits April 27, 2026 18:36
Adds an MDL script under mdl-examples/bug-tests/ exercising a
non-terminal custom error handler on a microflow call followed by a
continuation call. After exec, `mx check` reports 0 errors,
confirming the handler tail rejoins the continuation instead of
becoming a detached terminal path.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Symptom: a custom error handler for an output-producing action could rejoin
before a later DECLARE whose initial value referenced that output variable.
Studio Pro then rejected the roundtripped microflow because the output variable
is not in scope on the error-handler path.

Root cause: skip-variable routing collected references from many statement
kinds, but omitted DECLARE initial values.

Fix: include DECLARE initial values in statement reference analysis so handlers
wait for, or terminate before, output-dependent declarations.

Tests: add a graph-level regression that verifies the error-handler path cannot
reach an output-dependent DECLARE, plus the existing custom-handler routing
tests via make build and make test.
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.

Preserve custom error-handler routing during microflow roundtrip

2 participants