fix: TraceState spec compliance — ignore invalid input, never throw - #37
Merged
Conversation
Member
Author
|
Reviews welcome: @harshitt13 @kevmoo @muhammadkamel @rohit482 @cnbleu @yuzurihaaa @robert-northmind @benjaben @danexello — spec-compliance work against the OpenTelemetry specification; the PR description has the normative quotes and the red/green test commits. |
7 tasks
michaelbushe
force-pushed
the
fix/spec-tracestate-no-throw
branch
from
July 11, 2026 12:32
649491d to
e6bbf10
Compare
michaelbushe
force-pushed
the
fix/spec-tracestate-no-throw
branch
from
July 18, 2026 05:11
e6bbf10 to
a705023
Compare
specification/trace/api.md: mutating operations MUST validate input, MUST NOT return TraceState containing invalid data, and MUST follow the error-handling guidelines — which forbid throwing on misuse. Current put() throws ArgumentError on invalid key/value, and put()/remove() throw StateError before initialization. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Turns the red spec tests green: - put() with an invalid key or value warns and returns the state unchanged instead of throwing ArgumentError, so TraceState never contains invalid data and never crashes the caller - put()/remove() use getOrCreateDefault so they work without an installed SDK Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
michaelbushe
force-pushed
the
fix/spec-tracestate-no-throw
branch
from
July 18, 2026 05:32
a705023 to
6f94560
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Documents and fixes a spec violation found auditing against
specification/trace/api.md. TDD: first commit pins the spec contracts red (5 failing), second turns them green.The violation
TraceStatecontaining invalid data and MUST follow the general error handling guidelines" — and error-handling.md: "API methods MUST NOT throw unhandled exceptions when used incorrectly by end users."TraceState.putthrewArgumentErroron invalid keys/values; it now warns and returns the state unchanged, so the state stays valid and the caller never crashes.put/removealso threwStateError('Call initialize() first.')before initialization; they now lazily install the no-op factory like the rest of the API.Merge order
Stacked on #36: merge #36 first, then this. Note:
fix/tracestate-tenant-key-w3c(in-flight from another session) touches the same file — whichever merges second will need a small rebase.Validation
dart analyze/dart format --set-exit-if-changed .— cleandart test— 760 tests passing🤖 Generated with Claude Code