Skip to content

feat: propagate context through workflow execution - #158

Merged
timl3136 merged 7 commits into
cadence-workflow:mainfrom
timl3136:better-context
Aug 5, 2026
Merged

feat: propagate context through workflow execution#158
timl3136 merged 7 commits into
cadence-workflow:mainfrom
timl3136:better-context

Conversation

@timl3136

@timl3136 timl3136 commented Jul 29, 2026

Copy link
Copy Markdown
Member

What changed?
Context propagation

Why?
Necessary feature

How did you test it?
Unit and integration tests

Potential risks

Release notes

Documentation Changes

related issue: #160

@codecov

codecov Bot commented Jul 29, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 80.09259% with 43 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
cadence/sample/context_propagation_example.py 0.00% 32 Missing ⚠️
cadence/_internal/context.py 88.57% 2 Missing and 2 partials ⚠️
cadence/testing/_workflow_environment.py 92.59% 2 Missing and 2 partials ⚠️
cadence/_internal/workflow/workflow_engine.py 94.11% 0 Missing and 1 partial ⚠️
cadence/worker/_types.py 66.66% 1 Missing ⚠️
cadence/workflow.py 50.00% 1 Missing ⚠️
Files with missing lines Coverage Δ
cadence/__init__.py 100.00% <100.00%> (ø)
cadence/_internal/activity/_activity_executor.py 94.78% <100.00%> (+0.13%) ⬆️
cadence/_internal/activity/_context.py 93.10% <100.00%> (+0.44%) ⬆️
cadence/_internal/workflow/context.py 93.75% <100.00%> (+0.28%) ⬆️
cadence/activity.py 83.42% <100.00%> (+0.09%) ⬆️
cadence/client.py 88.10% <100.00%> (+0.64%) ⬆️
cadence/context.py 100.00% <100.00%> (ø)
cadence/error.py 95.04% <100.00%> (+0.04%) ⬆️
cadence/worker/_activity.py 100.00% <ø> (ø)
cadence/worker/_decision_task_handler.py 88.80% <100.00%> (+0.16%) ⬆️
... and 7 more
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Signed-off-by: Tim Li <ltim@uber.com>
Signed-off-by: Tim Li <ltim@uber.com>
Signed-off-by: Tim Li <ltim@uber.com>
Comment thread cadence/_internal/context.py
timl3136 and others added 3 commits August 4, 2026 11:57
Signed-off-by: Tim Li <ltim@uber.com>
Signed-off-by: Tim Li <ltim@uber.com>
@shijiesheng

Copy link
Copy Markdown
Member

I don't see places where we set the headers before start workflows.

@shijiesheng

Copy link
Copy Markdown
Member

Because it's in the inject() method, I read it wrong.

@timl3136
timl3136 enabled auto-merge (squash) August 5, 2026 20:01
@gitar-bot

gitar-bot Bot commented Aug 5, 2026

Copy link
Copy Markdown
Code Review ✅ Approved 1 resolved / 1 findings

Propagates context through workflow execution and adds missing propagators, addressing the previous finding regarding silently swallowed propagator inject/extract failures.

✅ 1 resolved
Quality: Propagator inject/extract failures are silently swallowed

📄 cadence/_internal/context.py:34-42 📄 cadence/_internal/context.py:70-83
inject_headers and extract_headers now catch all exceptions per-propagator, log, and continue (a behavior change from the previous raise-on-failure, reflected in the renamed test). For propagators carrying auth or tracing context, a transient inject/extract failure silently drops that context and the workflow/activity proceeds as if it never existed — a hard-to-diagnose correctness/security gap that only surfaces in logs. Consider making failure policy explicit (e.g. re-raise for required propagators, or surface a metric) so dropped context is observable rather than best-effort-only.

Options

Auto-apply is off → Gitar will not commit updates to this branch.
Display: compact → Showing less information.

Comment with these commands to change the behavior for this request:

Auto-apply Compact
gitar auto-apply:on         
gitar display:verbose         

Was this helpful? React with 👍 / 👎 | Gitar

@timl3136
timl3136 merged commit de888e0 into cadence-workflow:main Aug 5, 2026
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants