Skip to content

Fix TraceState key validation limits to match W3C spec #7575

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

priettt
Copy link

@priettt priettt commented Aug 15, 2025

Summary

This PR fixes the multi-tenant vendor key validation limits in ArrayBasedTraceStateBuilder to properly comply with the W3C Trace Context specification.

Changes:

  • Update MAX_VENDOR_ID_SIZE from 13 to 14 characters
  • Update MAX_TENANT_ID_SIZE from 240 to 241 characters
  • Update documentation and comments to reflect correct limits
  • Add test cases for boundary conditions

Background

The current implementation incorrectly rejects valid keys according to the W3C Trace Context specification. The rules define:

tenant-id = ( lcalpha / DIGIT ) 0*240( lcalpha / DIGIT / "_" / "-"/ "*" / "/" )
system-id = lcalpha 0*13( lcalpha / DIGIT / "_" / "-"/ "*" / "/" )

This means:

  • tenant-id: 1 + 240 = 241 characters maximum
  • system-id: 1 + 13 = 14 characters maximum

@priettt priettt requested a review from a team as a code owner August 15, 2025 04:05
Copy link

linux-foundation-easycla bot commented Aug 15, 2025

CLA Signed

  • ✅login: priettt / name: Francisco Prieto / (d3d2b16)

The committers listed above are authorized under a signed CLA.

Copy link

codecov bot commented Aug 15, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 90.00%. Comparing base (64acfd0) to head (d3d2b16).

Additional details and impacted files
@@             Coverage Diff              @@
##               main    #7575      +/-   ##
============================================
- Coverage     90.01%   90.00%   -0.01%     
  Complexity     7080     7080              
============================================
  Files           803      803              
  Lines         21417    21417              
  Branches       2086     2086              
============================================
- Hits          19278    19276       -2     
- Misses         1477     1478       +1     
- Partials        662      663       +1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

void testVendorIdLongerThan13Characters() {
assertThat(TraceState.builder().put("1@nrabcdefghijkl", FIRST_VALUE).build())
void testVendorIdWith14Characters() {
String key = "1@nrabcdefghijkl";
Copy link
Member

Choose a reason for hiding this comment

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

this is 16 chars

Copy link
Author

@priettt priettt Aug 18, 2025

Choose a reason for hiding this comment

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

Multi-tenant keys are formed with: a tenant-id, the "@" symbol, and a system-id (called vendor-id in the otel-java codebase).

This test verifies behavior for a system-id of 14 chars, so what follows the @ should be that long

Copy link
Contributor

@jkwatson jkwatson left a comment

Choose a reason for hiding this comment

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

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants