diff --git a/src/OpenTelemetry.Api/CHANGELOG.md b/src/OpenTelemetry.Api/CHANGELOG.md
index 55c3f63b434..70b7b035a0f 100644
--- a/src/OpenTelemetry.Api/CHANGELOG.md
+++ b/src/OpenTelemetry.Api/CHANGELOG.md
@@ -15,6 +15,11 @@ Notes](../../RELEASENOTES.md).
* Reduced allocations when constructing `SpanAttributes` from an array.
([#7698](https://github.com/open-telemetry/opentelemetry-dotnet/pull/7698))
+* Fixed parsing of an inbound `tracestate` header whose member value trimmed
+ to an empty value that previously threw an `IndexOutOfRangeException`
+ internally and could silently truncate the tracestate.
+ ([#7756](https://github.com/open-telemetry/opentelemetry-dotnet/pull/7756))
+
## 1.18.0
Released 2026-Aug-21
diff --git a/src/OpenTelemetry.Api/Context/Propagation/TraceStateUtils.cs b/src/OpenTelemetry.Api/Context/Propagation/TraceStateUtils.cs
index 3ec6857fcd8..4f66d28783c 100644
--- a/src/OpenTelemetry.Api/Context/Propagation/TraceStateUtils.cs
+++ b/src/OpenTelemetry.Api/Context/Propagation/TraceStateUtils.cs
@@ -1,7 +1,6 @@
// Copyright The OpenTelemetry Authors
// SPDX-License-Identifier: Apache-2.0
-using System.Diagnostics;
using System.Runtime.CompilerServices;
using OpenTelemetry.Internal;
@@ -26,9 +25,7 @@ internal static class TraceStateUtils
/// True if string was parsed successfully and tracestate was recognized, false otherwise.
internal static bool AppendTraceState(string traceStateString, List> tracestate)
{
- Debug.Assert(tracestate != null, "tracestate list cannot be null");
-
- if (string.IsNullOrEmpty(traceStateString))
+ if (tracestate is null || string.IsNullOrEmpty(traceStateString))
{
return false;
}
@@ -88,11 +85,7 @@ internal static bool AppendTraceState(string traceStateString, List value)
// Value is opaque string up to 256 characters printable ASCII RFC0020 characters (i.e., the range
// 0x20 to 0x7E) except comma , and =.
- if (value.Length > ValueMaxSize || value[value.Length - 1] == ' ' /* '\u0020' */)
+ if (value.Length == 0 || value.Length > ValueMaxSize || value[value.Length - 1] == ' ' /* '\u0020' */)
{
return false;
}
diff --git a/test/OpenTelemetry.Api.Tests/Context/Propagation/TracestateUtilsTests.cs b/test/OpenTelemetry.Api.Tests/Context/Propagation/TracestateUtilsTests.cs
index e9c0afecfa8..2efed684fe2 100644
--- a/test/OpenTelemetry.Api.Tests/Context/Propagation/TracestateUtilsTests.cs
+++ b/test/OpenTelemetry.Api.Tests/Context/Propagation/TracestateUtilsTests.cs
@@ -32,6 +32,9 @@ public void EmptyTracestate(string tracestate)
[InlineData("k\t=v")]
[InlineData("k=v,k=v")]
[InlineData("k1=v1,,,k2=v2")]
+ [InlineData("k=\t")]
+ [InlineData("k=\u000B")]
+ [InlineData("b=1,a=\t,c=2")]
[InlineData("k=morethan256......................................................................................................................................................................................................................................................")]
[InlineData("v=morethan256......................................................................................................................................................................................................................................................")]
public void InvalidTracestate(string tracestate)