Hacktoberfest 2026:維護者為十月標記出來的 issue,仍然開放、適合新手。 瀏覽 Hacktoberfest issue

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

未關閉
#2,008 0 則留言 0 個 reaction 已指派 1 人 在 GitHub 檢視

維護者通常 1 天內回覆

@maciejdudko 已經在處理了。

開始於 2026年10月22日。

  • #2009 來自 @RaphaelFakhri —— 未關閉

評估

這個 Issue 還沒有評估資料。

描述

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.

主要語言
Python
星號
1.2k
分支
269
平均合併
1 天 11 小時
30 天內合併 PR
68

環境準備

  • 沒有 Dockerfile 或 Docker Compose 檔案
  • 沒有 Pull Request 範本
  • 閱讀貢獻指南

從這裡開始

  1. 先讀完整個 Issue,再讀專案的貢獻指南。
  2. 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
  3. Fork 儲存庫,在一個分支上完成修改。
  4. 送出 Pull Request,並在描述裡引用這個 Issue 編號。

temporalio/sdk-python 的其他 Issue

查看 temporalio/sdk-python 的全部 Issue

相似的 Issue

更多 Python Issue

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。