Hacktoberfest 2026: die Issues, die Maintainer für den Oktober markiert haben – offen und einsteigerfreundlich. Hacktoberfest-Issues durchsuchen

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

Offen
#2,008 0 Kommentare 0 Reaktionen 1 zugewiesene Person Auf GitHub ansehen

Maintainer antworten meist innerhalb von 1 Tag

@maciejdudko arbeitet bereits daran.

Seit 22.10.2026.

  • #2009 von @RaphaelFakhri — offen

Bewertung

Dieses Issue wurde noch nicht bewertet.

Beschreibung

What are you really trying to do?

Terminate a standalone activity with ActivityHandle.terminate() and rely on the client's built-in RPC retries.

Describe the bug

_ClientImpl.terminate_activity in temporalio/client/_impl.py builds TerminateActivityExecutionRequest without request_id and sends it with retry=True. The sibling calls (cancel_activity, pause_activity, unpause_activity, start_activity) all set request_id=str(uuid.uuid4()), and the Go SDK sets RequestId on this request too.

On the server, an empty request ID is replaced with a new random one for each attempt (validateAndNormalizeRequestID in chasm/lib/activity/validator.go). Activity.Terminate returns success for a repeat only when the request ID matches the stored one, and otherwise returns NotFound: no running activity execution: it closed with status TERMINATED. So if the first attempt terminates the activity but the response is lost (for example a transient UNAVAILABLE), the automatic retry fails and terminate() raises although the activity was terminated.

Minimal Reproduction
from unittest import mock

import temporalio.api.workflowservice.v1
from temporalio.client import Client


async def main() -> None:
    rpc = mock.AsyncMock(
        return_value=temporalio.api.workflowservice.v1.TerminateActivityExecutionResponse()
    )
    service_client = mock.MagicMock()
    service_client.config.identity = "test-identity"
    service_client.workflow_service.terminate_activity_execution = rpc
    client = Client(service_client)
    await client.get_activity_handle("my-activity").terminate(reason="done")
    print(repr(rpc.call_args.args[0].request_id))  # prints '' on main
Environment/Versions
  • SDK: main at 600cbec
  • Python 3.13, Linux x86_64
Additional context

Adding request_id=str(uuid.uuid4()) to the request makes retries of the same call idempotent, matching the other activity operator calls.

Vorherrschende Sprache
Python
Sterne
1.2k
Forks
269
Ø Merge
1 T. 11 Std.
Gemergte PRs (30 T.)
68

Entwicklungsumgebung

Erste Schritte

  1. Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
  3. Forken Sie das Repository und arbeiten Sie in einem Branch.
  4. Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.

Mehr aus temporalio/sdk-python

Alle Issues in temporalio/sdk-python

Ähnliche Issues

Weitere Issues zu Python

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.