Commit f7855f6
Guard Activity.Current in GXSpanContext() to avoid NullReferenceException (#1291)
The parameterless GXSpanContext ctor dereferenced Activity.Current.Context with
no null check. When there is no active span — e.g. reading the current span
outside any started Activity, or in a CLI/batch procedure run (GXProcedure.
MainImpl) where no ambient span exists — Activity.Current is null and the ctor
threw a NullReferenceException (seen via SdtSpanContext.get_gxTpr_Spanid ->
new GXSpanContext()).
Use Activity.Current?.Context ?? default so an empty (all-zero) ActivityContext
is produced instead of crashing; TraceId/SpanId then return zeros rather than
throwing. Latent since the OpenTelemetry Spans API was added (#975), unrelated
to the recent dependency bump.
Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>1 parent a192187 commit f7855f6
1 file changed
Lines changed: 4 additions & 1 deletion
Lines changed: 4 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
118 | 118 | | |
119 | 119 | | |
120 | 120 | | |
121 | | - | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
122 | 125 | | |
123 | 126 | | |
124 | 127 | | |
| |||
0 commit comments