ref: Add support for custom sampling context to span first (14)#5628
Merged
GitHub Actions / warden: code-review
completed
Mar 11, 2026 in 3m 25s
1 issue
code-review: Found 1 issue (1 medium)
Medium
Custom sampling context can overwrite span data via key collision - `sentry_sdk/tracing_utils.py:1434`
The sampling_context.update(propagation_context.custom_sampling_context) call at line 1434 allows user-provided custom sampling context to overwrite the span key. If a user calls scope.set_custom_sampling_context({"span": {...}}), it would replace the span metadata populated at lines 1423-1430, causing the traces_sampler to receive incorrect or missing span information.
Duration: 3m 23s · Tokens: 1.2M in / 13.8k out · Cost: $1.55 (+extraction: $0.00, +fix_gate: $0.00)
Annotations
Check warning on line 1434 in sentry_sdk/tracing_utils.py
github-actions / warden: code-review
Custom sampling context can overwrite span data via key collision
The `sampling_context.update(propagation_context.custom_sampling_context)` call at line 1434 allows user-provided custom sampling context to overwrite the `span` key. If a user calls `scope.set_custom_sampling_context({"span": {...}})`, it would replace the span metadata populated at lines 1423-1430, causing the traces_sampler to receive incorrect or missing span information.
Loading