Skip to content

fix(local): show durable execution ARN as soon as the execution starts - #9205

Open
ParidelPooya wants to merge 1 commit into
aws:developfrom
ParidelPooya:fix/show-durable-execution-arn-at-start
Open

fix(local): show durable execution ARN as soon as the execution starts#9205
ParidelPooya wants to merge 1 commit into
aws:developfrom
ParidelPooya:fix/show-durable-execution-arn-at-start

Conversation

@ParidelPooya

Copy link
Copy Markdown

sam local invoke printed the durable execution ARN only after the execution reached a terminal state, and otherwise logged it at DEBUG. That ARN is the only identifier sam local execution get, history and stop accept, so an execution that was still running -- suspended on a callback, waiting out a context.wait, or interrupted with Ctrl-C -- could not be inspected without re-running the invoke under --debug and reading it out of the log.

--durable-execution-name is not a way around it. The emulator builds the ARN from a pair of generated UUIDs and keeps the name only as metadata, so the execution commands answer "Execution not found" when given a name. Nothing else about a running execution is missing: GetDurableExecution and GetDurableExecutionHistory both return data mid-flight, so the ARN was the only gap.

The ARN is now printed as soon as start_durable_execution returns, before the wait begins, together with the get/history/stop commands that work from another terminal while the execution runs. That mirrors the service, which returns the ARN in the X-Amz-Durable-Execution-Arn response header of Invoke -- the same header this code already builds for start-lambda and start-api callers, which is why the message is gated to the CLI path by the existing _is_cli_context() check. The completion summary is unchanged, so a short execution now names its ARN twice: at the start, where it is needed in order to poll, and at the end alongside the result.

The suggested commands are left unquoted, matching the existing completion output. Once the emulator emits service-shaped ARNs containing $LATEST, both call sites will need quoting, and that belongs with the ARN format change rather than here.

This covers the first of the three options #9200 offers. Listing local executions and accepting --durable-execution-name in the execution commands are not addressed here.

Testing: 86 unit tests pass across tests/unit/lib/utils/test_durable_formatters.py and tests/unit/local/docker/test_durable_lambda_container.py, five of them new -- the formatter, _show_execution_started in CLI context, in HTTP context and with no ARN, and an ordering test that asserts through a get_durable_execution side effect that the ARN was already printed by the time the execution was first polled. The existing sync wait_for_result test now expects both secho calls, in order. black, ruff and mypy clean.

Which issue(s) does this change fix?

Why is this change necessary?

How does it address the issue?

What side effects does this change have?

Mandatory Checklist

PRs will only be reviewed after checklist is complete

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@github-actions github-actions Bot added area/local/start-api sam local start-api command area/local/invoke sam local invoke command area/local/start-invoke pr/external stage/needs-triage Automatically applied to new issues and PRs, indicating they haven't been looked at. labels Aug 27, 2026
sam local invoke printed the durable execution ARN only after the execution reached a
terminal state, and otherwise logged it at DEBUG. That ARN is the only identifier sam
local execution get, history and stop accept, so an execution that was still running --
suspended on a callback, waiting out a context.wait, or interrupted with Ctrl-C -- could
not be inspected without re-running the invoke under --debug and reading it out of the
log.

--durable-execution-name is not a way around it. The emulator builds the ARN from a pair
of generated UUIDs and keeps the name only as metadata, so the execution commands answer
"Execution <name> not found" when given a name. Nothing else about a running execution is
missing: GetDurableExecution and GetDurableExecutionHistory both return data mid-flight,
so the ARN was the only gap.

The ARN is now printed as soon as start_durable_execution returns, before the wait
begins, together with the get/history/stop commands that work from another terminal while
the execution runs. That mirrors the service, which returns the ARN in the
X-Amz-Durable-Execution-Arn response header of Invoke -- the same header this code already
builds for start-lambda and start-api callers, which is why the message is gated to the
CLI path by the existing _is_cli_context() check. The completion summary is unchanged, so
a short execution now names its ARN twice: at the start, where it is needed in order to
poll, and at the end alongside the result.

The suggested commands are left unquoted, matching the existing completion output. Once
the emulator emits service-shaped ARNs containing $LATEST, both call sites will need
quoting, and that belongs with the ARN format change rather than here.

assert_invoke_output in the integration base used to find the summary's ARN by taking the
first "ARN:" match in stdout; the banner now precedes it. The value is the same either way,
so nothing failed, but the helper had stopped proving that the summary carries the ARN. The
lookup is now anchored to the summary section, and the banner is asserted separately, so
both halves of the user-visible output are covered.

This covers the first of the three options aws#9200 offers. Listing local executions and
accepting --durable-execution-name in the execution commands are not addressed here.

Testing: 86 unit tests pass across tests/unit/lib/utils/test_durable_formatters.py and
tests/unit/local/docker/test_durable_lambda_container.py, five of them new -- the
formatter, _show_execution_started in CLI context, in HTTP context and with no ARN, and an
ordering test that asserts through a get_durable_execution side effect that the ARN was
already printed by the time the execution was first polled. The existing sync
wait_for_result test now expects both secho calls, in order. The durable integration tests
need Docker and were not run; the reworked assertions in assert_invoke_output were checked
against a reconstruction of a full invoke stdout, confirming the anchored lookup returns
the summary ARN and that the banner assertions hold. black, ruff and mypy clean.
@ParidelPooya
ParidelPooya force-pushed the fix/show-durable-execution-arn-at-start branch from d194dd6 to 2babdb7 Compare August 27, 2026 19:00
@ParidelPooya
ParidelPooya marked this pull request as ready for review August 27, 2026 20:44
@ParidelPooya
ParidelPooya requested a review from a team as a code owner August 27, 2026 20:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/local/invoke sam local invoke command area/local/start-api sam local start-api command area/local/start-invoke pr/external stage/needs-triage Automatically applied to new issues and PRs, indicating they haven't been looked at.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants