[Bug] `retry_policy` not set in `ativity.info()` despite being defined in the `workflow.execute_activity()` call
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
Can you validate on a dev or real server as well? There are some things the time skipping server does differently from the standard servers.
@brent-cybrid is a colleague of mine. We see this in Temporal Cloud as well.
@michael-cybrid @brent-cybrid temporal cloud has received several updates since this bug report. Could you please confirm is you're still seeing this issue?
I've confirmed that retry_policy is in fact present when tested against cloud: https://github.com/temporalio/sdk-python/pull/1389
So ultimately this is really a time skipping test server issue, which is partly due to https://github.com/temporalio/sdk-java/issues/1426
But... we're in the process of adding proper time skipping support to the real server, at which point we can retire the Java one. Closing this since we're unlikely to prioritize minor Java test server things in light of that.
We still see this issue. It was raised to to the support team in with a support ticket (17450) on April 7, with multiple references to production workflow runs that exhibit this behaviour. Still have not received support. Disappointed in the support we receive as a Temporal Cloud customer.
Reliability note for anyone depending on activity.info().retry_policy at runtime:
When the workflow defines a retry policy but the activity info surface does not echo it, operators lose the expected-vs-actual signal they use to debug “why did this retry / why didn’t it?” That turns a configured policy into a silent observability gap.
Fail-closed pattern while the SDK path is fixed:
- Treat the workflow-declared retry policy as source of truth; do not branch control logic on
activity.info().retry_policyuntil it is proven present. - At activity start, emit a structured log:
{stage: "activity_start", activity, attempt, retry_policy_present, max_attempts}. Ifretry_policy_present=falsedespite workflow config, markstatus=config_echo_missing. - Assert in a unit/integration test that a workflow with an explicit
RetryPolicy(maximum_attempts=N)yields the same N (or a non-null policy object) onactivity.info()— so this cannot regress without CI noise. - For production alarms, page on attempt >= threshold from the worker metrics path, not from the missing info field.
This is pure free diagnostic framing for silent config-echo failures — not a product pitch.
Hey all, I wanted to share an update here. We recently discovered a code path in the Temporal server that left retry_policy out of the response when eager activity execution is requested. An upcoming Temporal Cloud release will contain the fix.
For those that are unfamiliar with eager execution, it's an optimization that reduces the number of round trips to the server in the case that the worker scheduling the activity is able to immediately execute the activity. This setting is enabled by default in the SDK.
This issue surfaces when:
- The activity is scheduled on the same task queue as the workflow.
- The worker processing the workflow task is configured with activities and has an available activity slot.
- Eager activity execution is enabled by both the worker and the Temporal server.
@michael-cybrid Have you had any issues with this recently? We believe this should be fixed now per @VegetarianOrc 's comment.
Wanted to add some context that the fix identified is included in Temporal v1.32.0