Skip to content

fix: don't require the installation ID to be a UUID - #2177

Merged
tustanivsky merged 3 commits into
masterfrom
feat/arbitrary-installation-id
Oct 8, 2026
Merged

tustanivsky merged 3 commits into
masterfrom
feat/arbitrary-installation-id

Conversation

@tustanivsky

@tustanivsky tustanivsky commented Oct 8, 2026 •

Copy link
Copy Markdown
Collaborator

Follow-up to #2150: the persisted installation ID is stored and read back as a UUID, but the user.id it backs is free-form in the protocol, so there's no reason for the SDK to impose a format of its own as it forces anything that wants to supply an ID to pad or hash it into UUID shape first.

Key Changes

  • Line 1 of <database>/installation_id is now read up to the newline instead of as a fixed 36 bytes, so the file can hold an ID of any length. A trailing \r is trimmed, and IDs longer than 128 characters are rejected so a corrupt file can't produce an absurd user.id.
  • Existing files keep working unchanged: a stored <uuid>\n<public_key>\n parses exactly as before, and rotation when the DSN's public key changes is unaffected.
  • The ID is carried as an owned string rather than a fixed 37-byte buffer. A generated ID is still a random UUIDv4, so nothing changes for anyone not supplying their own.
  • Tests cover a non-UUID ID written to the file and loaded back as-is; the UUID shape assertions now apply only when no integration provides one.

Related Items

Read line 1 of <database>/installation_id up to the newline instead of as a
fixed 36 bytes, so the file can hold an ID of any length, and accept any
non-empty, newline-free ID of up to 128 characters from a platform
integration. Existing files parse exactly as before and a generated ID is
still a random UUIDv4.

user.id is free-form in the protocol, so there is no reason for the SDK to
impose a format of its own on the ID that backs it.
@tustanivsky
tustanivsky marked this pull request as ready for review October 8, 2026 07:11
Comment thread src/sentry_database.c
The reader trims line 1 of the file, so an ID with surrounding whitespace
was reported as-is on the run that created it and in its trimmed form on
every run after, changing user.id once. Trim on the way in as well, and
reject an embedded newline over the trimmed span.
The installation ID no longer has to be a UUID, so stop asserting its
length. In test_scope.c the neighbouring checks already cover that the ID is
present and that the event's user ID matches it; in test_session.c the check
is all that covers `did`, so it only asserts the value is set.
Comment thread src/sentry_database.c
? options->dsn->public_key
: "";
const size_t key_len = strlen(public_key);
const size_t max_id_len = 128;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@codecov

codecov Bot commented Oct 8, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 78.12500% with 7 lines in your changes missing coverage. Please review.
✅ Project coverage is 75.43%. Comparing base (a22b118) to head (2484fe4).
⚠️ Report is 1 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #2177      +/-   ##
==========================================
- Coverage   75.47%   75.43%   -0.05%     
==========================================
  Files         103      103              
  Lines       28079    28089      +10     
  Branches     5147     5150       +3     
==========================================
- Hits        21194    21189       -5     
- Misses       5538     5558      +20     
+ Partials     1347     1342       -5     
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@tustanivsky
tustanivsky merged commit d020087 into master Oct 8, 2026
72 checks passed
@tustanivsky
tustanivsky deleted the feat/arbitrary-installation-id branch October 8, 2026 09:09
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