Hacktoberfest 2026: los issues que los mantenedores marcaron para octubre, abiertos y aptos para principiantes. Explorar issues de Hacktoberfest

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

Abierto
#2,008 0 comentarios 0 reacciones 1 asignado Ver en GitHub

Los mantenedores suelen responder en 1 día

@maciejdudko ya está trabajando en esto.

Desde el 22/10/2026.

  • #2009 de @RaphaelFakhri — abierto

Evaluación

Este issue todavía no se ha evaluado.

Descripción

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.

Lenguaje dominante
Python
Estrellas
1.2k
Forks
269
Merge medio
1 d 11 h
PR fusionados (30 d)
68

Preparar el entorno

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de temporalio/sdk-python

Todos los issues de temporalio/sdk-python

Issues similares

Más issues de Python

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.