-
Notifications
You must be signed in to change notification settings - Fork 139
Open
Labels
bugSomething isn't workingSomething isn't working
Description
What are you really trying to do?
We're trying to access the retry_policy from the activity.info from within an activity.
Describe the bug
retry_policy isn't set even though it's set on the workflow.execute_activity call.
Minimal Reproduction
#!/usr/bin/env python3
"""
Minimal reproducible example demonstrating Temporal SDK bug:
activity.info().retry_policy is None even when workflow specifies retry_policy
This script is standalone and only requires: pip install temporalio
"""
import asyncio
from datetime import timedelta
from temporalio import activity, workflow
from temporalio.common import RetryPolicy
from temporalio.testing import WorkflowEnvironment
from temporalio.worker import Worker
# Simple activity that captures what retry_policy information it receives
@activity.defn
async def check_retry_policy_activity() -> dict:
"""Activity that returns information about the retry_policy it receives."""
info = activity.info()
return {
'has_retry_policy_attr': hasattr(info, 'retry_policy'),
'rety_policy_is_set': info.retry_policy is not None if hasattr(info, 'retry_policy') else False,
'non_retryable_error_types': (
info.retry_policy.non_retryable_error_types
if (
hasattr(info, 'retry_policy')
and hasattr(info.retry_policy, 'non_retryable_error_types')
)
else None
)
}
# Simple workflow that specifies retry_policy with non_retryable_error_types
@workflow.defn
class RetryPolicyTestWorkflow:
"""Workflow that calls activity with specific retry_policy."""
@workflow.run
async def run(self) -> dict:
# Execute activity with retry_policy that includes non_retryable_error_types
return await workflow.execute_activity(
check_retry_policy_activity,
start_to_close_timeout=timedelta(seconds=10),
retry_policy=RetryPolicy(
non_retryable_error_types=["MyNonRetryableError", "AnotherNonRetryableError"]
),
)
async def main():
"""Run the test workflow and verify retry_policy is available in activity."""
async with await WorkflowEnvironment.start_time_skipping() as env:
# Create worker with our workflow and activity
async with Worker(
env.client,
task_queue="test-queue",
workflows=[RetryPolicyTestWorkflow],
activities=[check_retry_policy_activity],
):
# Execute the workflow
result = await env.client.execute_workflow(
RetryPolicyTestWorkflow.run,
id="test-workflow-retry-policy",
task_queue="test-queue",
)
# Verify the bug
if result['rety_policy_is_set']:
return True
else:
print("BUG PRESENT: retry_policy is not set, even though workflow specifies it")
return False
if __name__ == "__main__":
success = asyncio.run(main())
exit(0 if success else 1)Environment/Versions
Temporal Cloud
Additional context
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working