Skip to content

fix(span-components): only compress canonical UUIDs in V3 - #1161

Merged
Abhijeet Prasad (AbhiPrasad) merged 1 commit into
mainfrom
fix/v3-strict-uuid-compression
Nov 20, 2026
Merged

Abhijeet Prasad (AbhiPrasad) merged 1 commit into
mainfrom
fix/v3-strict-uuid-compression

Conversation

@AbhiPrasad

@AbhiPrasad Abhijeet Prasad (AbhiPrasad) commented Nov 20, 2026 •

Copy link
Copy Markdown
Member

Summary

_try_make_uuid in span_identifier_v3.py compressed any value that uuid.UUID() accepts. That includes 32-char hex, {braced}, urn:uuid: and uppercase forms. V3 decoding always returns the canonical lowercase dashed form, so those IDs came back changed after a round trip. For example, 4bf92f35…4736 came back as 4bf92f35-77b3-…-4736.

The SDK only exports V3 under BRAINTRUST_LEGACY_IDS, where it generates canonical UUIDs itself, so this is narrow. One path can still hit it: a service with legacy IDs imports a parent from a default-mode (hex ID) service, then re-exports a child span. The child's root_span_id gains dashes, and anything continuing from that slug splits from the original trace.

Fix

Compress a value only when str(UUID(s)) == s, meaning it is already a canonical UUID. Any other value goes into V3's JSON section unchanged. Decoding is unchanged, so existing slugs and other V3 readers still work, and canonical UUIDs encode to the same bytes as before.

Tests

  • Replaced test_otel_ids_fail_roundtrip, which asserted the buggy behavior, with test_otel_ids_roundtrip_unchanged. It checks that hex object_id, span_id and root_span_id round-trip exactly.
  • Added a parametrized test that round-trips uppercase, braced, urn:uuid: and undashed UUID strings.
  • Red → green: the new tests failed before the fix (5 failed) and pass after it.
  • nox -s test_core: 1229 passed, 112 skipped, 12 xfailed.
  • nox -s "test_temporal(latest)": 27 passed. The Temporal plugin decodes V3 slugs, and that path is unchanged.

🤖 Generated with Claude Code

Co-authored by StarfolkAI (@starfolkai)[bot]

`_try_make_uuid` accepted anything `uuid.UUID()` parses: 32-char hex,
braces, `urn:uuid:` and uppercase. Decoding always returns the canonical
dashed form, so those IDs came back altered. A hex trace ID re-exported
under BRAINTRUST_LEGACY_IDS would gain dashes and split the trace.

Compress only when the value is already a canonical UUID string. Any
other value goes into the JSON section unchanged. Decoding is the same
as before, so existing slugs and other V3 readers keep working.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 20, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-20T18:08:12.992423Z 5d44a13 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@AbhiPrasad
Abhijeet Prasad (AbhiPrasad) merged commit d3f5d00 into main Nov 20, 2026
98 checks passed
@AbhiPrasad
Abhijeet Prasad (AbhiPrasad) deleted the fix/v3-strict-uuid-compression branch November 20, 2026 18:21
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.

1 participant