Skip to content

feat: add types and helper function for context propagation#152

Open
timl3136 wants to merge 9 commits into
cadence-workflow:mainfrom
timl3136:context-propagation-primitives
Open

feat: add types and helper function for context propagation#152
timl3136 wants to merge 9 commits into
cadence-workflow:mainfrom
timl3136:context-propagation-primitives

Conversation

@timl3136

@timl3136 timl3136 commented Jul 13, 2026

Copy link
Copy Markdown
Member

What changed?
Add types and helper function for context propagation

Why?
This is first commit in stacked branches aiming to implement context propagation in python client

How did you test it?
unit test

Potential risks

Release notes

Documentation Changes

timl3136 added 2 commits July 13, 2026 13:07
Signed-off-by: Tim Li <ltim@uber.com>
Signed-off-by: Tim Li <ltim@uber.com>
@timl3136 timl3136 force-pushed the context-propagation-primitives branch from 7cdf162 to 0d8e1f2 Compare July 13, 2026 20:07
Comment thread cadence/_internal/context_propagation.py
Comment thread cadence/_internal/context_propagation.py
@codecov

codecov Bot commented Jul 13, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 74.32432% with 19 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
cadence/_internal/context_propagation.py 72.46% 14 Missing and 5 partials ⚠️
Files with missing lines Coverage Δ
cadence/context.py 100.00% <100.00%> (ø)
cadence/error.py 95.04% <100.00%> (+0.04%) ⬆️
cadence/_internal/context_propagation.py 72.46% <72.46%> (ø)
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@timl3136 timl3136 force-pushed the context-propagation-primitives branch from cb8b162 to 0d8e1f2 Compare July 13, 2026 20:19
timl3136 and others added 7 commits July 13, 2026 13:29
Signed-off-by: Tim Li <ltim@uber.com>
Signed-off-by: Tim Li <ltim@uber.com>
…cadence-python-client into context-propagation-primitives
Signed-off-by: Tim Li <ltim@uber.com>
Signed-off-by: Tim Li <ltim@uber.com>
…cadence-python-client into context-propagation-primitives
@gitar-bot

gitar-bot Bot commented Jul 13, 2026

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

Adds context propagation primitives including the ContextPropagator protocol and propagation engine. Addresses missing unit tests and refines error handling to prevent double-wrapping of ContextPropagationError.

✅ 2 resolved
Quality: New context-propagation primitives have no unit tests

📄 cadence/_internal/context_propagation.py:1-15 📄 cadence/context.py:1-15
These new primitives contain non-trivial logic (mapping/type validation, duplicate-header detection, ExitStack-based scope teardown with nested cleanup error handling) but ship with no tests and no callers. Add unit tests covering: duplicate header rejection, non-mapping/non-bytes inject returns, extract failure triggering stack.close(), and cleanup errors surfacing as ContextPropagationError. This locks in the intended error semantics before consumers depend on them.

Quality: inject() error handling double-wraps ContextPropagationError

📄 cadence/_internal/context_propagation.py:33-38 📄 cadence/_internal/context_propagation.py:90-99
In context_propagation_scope, the extract loop deliberately re-raises ContextPropagationError before the generic except Exception to avoid double-wrapping. inject_context_fields does not do this: a ContextPropagationError raised inside a propagator's inject() is caught by the bare except Exception and re-wrapped into a generic "inject failed" error, obscuring the original message. For consistency, add an except ContextPropagationError: raise clause before the broad handler in the inject path.

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 changed the title feat: add context propagation primitives feat: add types and helper function for context propagation Jul 13, 2026
@gitar-bot

gitar-bot Bot commented Jul 13, 2026

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

Adds context propagation primitives including the ContextPropagator protocol and propagation engine. Addresses missing unit tests and refines error handling to prevent double-wrapping of ContextPropagationError.

✅ 2 resolved
Quality: New context-propagation primitives have no unit tests

📄 cadence/_internal/context_propagation.py:1-15 📄 cadence/context.py:1-15
These new primitives contain non-trivial logic (mapping/type validation, duplicate-header detection, ExitStack-based scope teardown with nested cleanup error handling) but ship with no tests and no callers. Add unit tests covering: duplicate header rejection, non-mapping/non-bytes inject returns, extract failure triggering stack.close(), and cleanup errors surfacing as ContextPropagationError. This locks in the intended error semantics before consumers depend on them.

Quality: inject() error handling double-wraps ContextPropagationError

📄 cadence/_internal/context_propagation.py:33-38 📄 cadence/_internal/context_propagation.py:90-99
In context_propagation_scope, the extract loop deliberately re-raises ContextPropagationError before the generic except Exception to avoid double-wrapping. inject_context_fields does not do this: a ContextPropagationError raised inside a propagator's inject() is caught by the bare except Exception and re-wrapped into a generic "inject failed" error, obscuring the original message. For consistency, add an except ContextPropagationError: raise clause before the broad handler in the inject path.

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

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.

1 participant