temporalio / sdk-python

Temporal Python SDK
MIT License
474 stars 77 forks source link

[Bug] Coroutine Raised StopIteration when triggering workflow execution from CLI for workflows which call workflow.upsert_search_attributes #443

Closed alonwengierko closed 11 months ago

alonwengierko commented 12 months ago

What are you really trying to do?

I modified poetry file to use temporalio version 1.4.0 and then ran worker.py of your_visibility folder of the DOCUMENTATION_SAMPLES_PYTHON repository (https://github.com/temporalio/documentation-samples-python)

Then I use cli command to trigger workflow

temporal workflow start --task-queue search-attributes-task-queue --type GreetingWorkflow

After doing that I get an error: "coroutine raised StopIteration"

This error doesn't happen for version Python SDK 1.3.0 when I trigger workflow from cli

Describe the bug

I found that when you trigger a workflow who has calls to workflow.upsert_search_attributes using cli for for Temporalio Python SDK version 1.4.0, you get error Coroutine Raised StopIteration

File "/Users/awengierko/Documents/Projects/documentation-samples-python/.venv/lib/python3.11/site-packages/temporalio/worker/_workflow_instance.py", line 1888, in execute_workflow return await input.run_fn(*args) ^^^^^^^^^^^^^^^^^^^^^^^^^ RuntimeError: coroutine raised StopIteration Failed activation on workflow GreetingWorkflow with ID 9e14f703-b1de-4031-9213-fb43b405a660 and run ID cf74cb1b-0bb2-4d08-a711-312c3f050cfb

Screenshot 2023-12-08 at 21 11 10 Screenshot 2023-12-08 at 21 11 18

Minimal Reproduction

  1. Clone repo https://github.com/temporalio/documentation-samples-python
  2. Update pyproject.toml to use temporalio = "^1.4.0" instead of temporalio = "^1.3.0"
  3. Terminal 1 -> Run worker: python worker.py
  4. Terminal 2 -> Trigger Workflow exeuction: temporal workflow start --task-queue search-attributes-task-queue --type GreetingWorkflow
  5. See in Terminal 2: Error message "coroutine raised StopIteration"

Environment/Versions

cretz commented 11 months ago

Thanks! I believe this was just fixed in https://github.com/temporalio/sdk-python/pull/440 but not yet released. In the meantime, I recommend using typed search attributes for upsert_search_attributes (you should be getting a warning if you use this deprecated form). I will see if I can have the docs updated to match.

(closing since the primary issue was fixed, but feel free to continue to discuss here, on the forums, or on Slack)