Skip to content

Send a request ID when terminating a standalone activity - #2009

Open
RaphaelFakhri wants to merge 3 commits into
temporalio:mainfrom
RaphaelFakhri:fix-terminate-activity-request-id
Open

RaphaelFakhri wants to merge 3 commits into
temporalio:mainfrom
RaphaelFakhri:fix-terminate-activity-request-id

Conversation

@RaphaelFakhri

Copy link
Copy Markdown
Contributor

What was changed

terminate_activity in the client now sets request_id on TerminateActivityExecutionRequest, the same way cancel_activity, pause_activity and unpause_activity already do. Adds a unit test in tests/test_activity.py and a changelog fragment.

Why?

The client sends TerminateActivityExecution with retry=True, but without a request ID. The server fills in a new random ID for each attempt and only treats a terminate as a duplicate when the request ID matches the one it stored. If the first attempt terminates the activity and its response is lost, the retry carries a different ID, so the server returns NotFound: no running activity execution: it closed with status TERMINATED and ActivityHandle.terminate() raises even though the activity was terminated. The Go SDK sets RequestId on this request.

Checklist

  1. Closes [Bug] Retried ActivityHandle.terminate() can fail after the activity is already terminated #2008

  2. How was this tested:

    • New test test_terminate_activity_generates_request_id mocks the workflow service and checks that each terminate() call sends a distinct UUID4 request ID, following test_start_activity_generates_request_id. Without the source change it fails with ValueError: badly formed hexadecimal UUID string because request_id is empty. With the change it passes, and all 35 tests in tests/test_activity.py pass against a local dev server.
    • ruff check --select I, ruff format --check, pyright, basedpyright, mypy and pydocstyle pass on the changed files.
  3. Any docs updates needed?
    No.

@RaphaelFakhri
RaphaelFakhri requested a review from a team as a code owner October 22, 2026 12:30
@maciejdudko maciejdudko self-assigned this Oct 22, 2026

This branch has not been deployed

No deployments
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.

[Bug] Retried ActivityHandle.terminate() can fail after the activity is already terminated

2 participants