Repository navigation
Conversation
Scope baggage replacement and every static mutation to the current execution context by default. Add a startup AppContext switch to restore unsafe legacy sharing temporarily, with migration guidance and regression coverage for both modes and cached configuration. The default behavior change still requires maintainer release approval. Discovered by Anthropic's OSS Scanner, as bug ANT-2026-YXEDG1G8.
Pull request dashboard statusWaiting on the author · refreshed 2026-11-10 13:04 UTC Respond to 2 review items (e.g. link a commit, explain why not, ask a follow-up): Status above doesn't look right?
|
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #8042 +/- ##
==========================================
- Coverage 93.03% 93.01% -0.03%
==========================================
Files 398 400 +2
Lines 23473 23734 +261
Branches 4389 4439 +50
==========================================
+ Hits 21838 22075 +237
- Misses 1115 1125 +10
- Partials 520 534 +14
Flags with carried forward coverage won't be shown. Click here to find out more.
|
Use the existing TemporaryDirectory helper for isolated startup-mode test directories and link its source into the API test project. Discovered by Anthropic's OSS Scanner, as bug ANT-2026-YXEDG1G8.
Remove startup-mode and caching tests and their unused helper include. Keep the baggage regressions focused on the safe default behavior. Discovered by Anthropic's OSS Scanner, as bug ANT-2026-YXEDG1G8.
Link the AppContext documentation, add the ASP.NET Web.config example, and clarify the warning about insecure legacy baggage flow. Discovered by Anthropic's OSS Scanner, as bug ANT-2026-YXEDG1G8. Co-authored-by: Martin Costello <martin@martincostello.com>
|
Waiting on anything else to merge this? |
|
I would like to have opinion from @alanwest or @rajkumar-rangaraj here. I hope they will find some time to review. |
rajkumar-rangaraj
left a comment
There was a problem hiding this comment.
LGTM on the direction and the implementation. Isolating writes matches the spec's immutable-context model, and the opt-out switch gives users a migration path. A few things before merging:
Breaking default: this is essentially #5208, which was reverted in #5227 after user feedback that baggage set in awaited helpers no longer flowed back to the caller. Since this changes stable OpenTelemetry.Api 1.x behavior, can we confirm it at the SIG and call it out prominently in the release notes?
Timing: 1.21.0-rc.2 shipped today. I'd prefer this not go straight into 1.21.0 stable without an RC. Either cut another RC or merge after 1.21.0.
Contrib impact: ASP.NET TelemetryHttpModule saves the baggage holder object at request start and puts it back when the async context is lost (ActivityHelper.cs). With this change that restore rolls baggage back to its request-start value. If there was no incoming baggage, nothing is restored. I'll open a contrib follow-up so it saves the current Baggage value instead.
Nit: the legacy-switch path no longer has tests. That's fine since the code is unchanged, but worth noting.
PR open-telemetry/opentelemetry-dotnet-contrib#5948 is ready. It can be merged even now, to avoid problems if anybody update only API and forgot to update instrumentation package.
Intentionally omited. |
I hope it will work for you:
|
This fix addresses a ANT-2026-YXEDG1G8 finding from Anthropic's OSS Scanner.
Project enrollment: anthropics/oss-scanner#117.
Fixes #7449, it is 3rd attempt to solve this. This time, with AppContext opt-out switch.
Is is similar to was done directly in .NET for https://learn.microsoft.com/en-us/dotnet/core/compatibility/serialization/10/xmlserializer-obsolete-properties
Changes
Ambient baggage writes now publish a replacement holder in the current execution
context, so they no longer change baggage observed by previously forked contexts.
The correction covers
Baggage.Currentand every static baggage mutator, withboth explicit and omitted baggage arguments. It addresses the behavior tracked
in #7449.
This is a breaking behavior change: enrichment performed in an awaited
asynchronous helper no longer flows back to its caller. Enable the
OpenTelemetry.Baggage.AllowUnsafeLegacyFlowAppContext switch at startup totemporarily restore the original shared holder and locking behavior. An unset
or false switch keeps isolation. The selected mode is cached when Baggage
initializes; later configuration changes do not update it.
The API documentation explains the unsafe sharing risk and shows how to migrate
by returning updated baggage to the caller. No public signatures or dependencies
change.
The compatibility option is a migration aid, not a claim of backward compatibility
or an approved 1.x release exception. The history in #5208, #5227, and #7191.
Merge requirement checklist
CHANGELOG.mdfile(s) updated for non-trivial changesNote
This PR description was generated with OpenAI Codex.
Footnotes
Yes, I can answer maintainer questions about the content of this PR without using AI. ↩