Skip to content

[API] Handle empty tracestate value - #7756

Merged
Kielek merged 4 commits into
open-telemetry:mainfrom
martincostello:fix-tracestate-parse
Sep 16, 2026
Merged

Kielek merged 4 commits into
open-telemetry:mainfrom
martincostello:fix-tracestate-parse

Conversation

@martincostello

Copy link
Copy Markdown
Member

Found by Claude Code scan of the repository.

Changes

Avoid an internal IndexOutOfRangeException if a tracestate value was empty once trimmed.

Merge requirement checklist

  • CONTRIBUTING guidelines followed (license requirements, nullable enabled, static analysis, etc.)
  • Unit tests added/updated
  • Appropriate CHANGELOG.md files updated for non-trivial changes
  • Changes in public API reviewed (if applicable)

Avoid an internal `IndexOutOfRangeException` if a `tracestate` value was empty once trimmed.
@github-actions github-actions Bot added the pkg:OpenTelemetry.Api Issues related to OpenTelemetry.Api NuGet package label Sep 15, 2026
Remove Debug.Assert() and instead just return false if it were null.
@codecov

codecov Bot commented Sep 15, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 66.66667% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 91.86%. Comparing base (7dbd68d) to head (b33a0fa).
⚠️ Report is 1 commits behind head on main.
✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
...lemetry.Api/Context/Propagation/TraceStateUtils.cs 66.66% 1 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #7756      +/-   ##
==========================================
+ Coverage   91.85%   91.86%   +0.01%     
==========================================
  Files         337      337              
  Lines       18399    18399              
==========================================
+ Hits        16901    16903       +2     
+ Misses       1498     1496       -2     
Flag Coverage Δ
unittests-Project-Experimental 91.98% <66.66%> (+<0.01%) ⬆️
unittests-Project-Stable 91.97% <66.66%> (+0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
...lemetry.Api/Context/Propagation/TraceStateUtils.cs 91.57% <66.66%> (-1.06%) ⬇️

... and 2 files with indirect coverage changes

Comment thread src/OpenTelemetry.Api/CHANGELOG.md Outdated
Comment thread src/OpenTelemetry.Api/CHANGELOG.md Outdated
Add PR number and fix typo.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

The fix is correct and adequately tested; the remaining feedback is cosmetic.

Pull request overview

Prevents empty trimmed tracestate values from causing internal exceptions.

Changes:

  • Rejects empty values safely and clears partial results.
  • Adds regression coverage for whitespace-only values.
  • Documents the fix.
File summaries
File Description
TraceStateUtils.cs Safely validates empty values.
TracestateUtilsTests.cs Adds regression cases.
CHANGELOG.md Records the behavioral fix.
Review details
  • Files reviewed: 3/3 changed files
  • Comments generated: 1
  • Review effort level: Balanced

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread src/OpenTelemetry.Api/CHANGELOG.md Outdated
Comment thread src/OpenTelemetry.Api/CHANGELOG.md Outdated
Fix typo in CHANGELOG entry.
@martincostello
martincostello marked this pull request as ready for review September 15, 2026 16:43
@martincostello
martincostello requested a review from a team as a code owner September 15, 2026 16:43
@martincostello
martincostello added this pull request to the merge queue Sep 15, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to no response for status checks Sep 15, 2026
@martincostello
martincostello added this pull request to the merge queue Sep 15, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to no response for status checks Sep 15, 2026
@martincostello
martincostello added this pull request to the merge queue Sep 15, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Sep 15, 2026
@Kielek
Kielek added this pull request to the merge queue Sep 16, 2026
Merged via the queue into open-telemetry:main with commit 0c604ae Sep 16, 2026
79 checks passed
This was referenced Sep 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pkg:OpenTelemetry.Api Issues related to OpenTelemetry.Api NuGet package

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants