Skip to content

Conversation

@vaind
Copy link
Contributor

@vaind vaind commented Oct 17, 2025

Summary

Automatically extracts build ID from the version string read from sentry.h when downstream SDKs modify it to include build metadata in semver format.

Fixes the issue where both SENTRY_VERSION and BUILD fields contained the full version with build metadata (e.g., 0.11.3+20251016-9e31c9f-dirty).

Problem

When downstream SDKs modify sentry.h to include the full version with build ID and also set SENTRY_BUILD_ID via CMake, the embedded library info duplicates the build ID:

SENTRY_VERSION:0.11.3+20251016-9e31c9f-dirty;PLATFORM:scarlett;BUILD:0.11.3+20251016-9e31c9f-dirty;...

Solution

The CMake configuration now:

  1. Parses the version from sentry.h and extracts any build metadata after the + character
  2. Uses only the base version (major.minor.patch) for SENTRY_VERSION field
  3. Uses the extracted build ID for the BUILD field
  4. Still respects the SENTRY_BUILD_ID cache variable if explicitly set (takes precedence)
  5. Falls back to timestamp if no build ID is found

Result

Embedded library info now correctly separates version and build ID:

SENTRY_VERSION:0.11.3;PLATFORM:scarlett;BUILD:20251016-9e31c9f-dirty;...

Changes

Testing

  • Unit tests verify that SENTRY_VERSION contains only base version without build metadata
  • New test validates that BUILD field is present and non-empty
  • Existing tests updated to handle both formats (with and without build metadata in source)

🤖 Generated with Claude Code

When downstream SDKs modify sentry.h to include build metadata in the
version string (e.g., 0.11.3+20251016-9e31c9f-dirty), the embedded
library info now automatically extracts the build ID from the version.

Changes:
- Parse build metadata from SENTRY_VERSION_FULL if present
- Use base version (major.minor.patch) for SENTRY_VERSION field
- Use extracted build ID for BUILD field
- SENTRY_BUILD_ID cache variable still takes precedence
- Update template to use new SENTRY_EMBEDDED_VERSION and SENTRY_EMBEDDED_BUILD_ID
- Update tests to validate base version format
- Add test for build ID field

This ensures the embedded info format is:
SENTRY_VERSION:0.11.3;BUILD:20251016-9e31c9f-dirty
instead of:
SENTRY_VERSION:0.11.3+20251016-9e31c9f-dirty;BUILD:0.11.3+20251016-9e31c9f-dirty

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
@github-actions
Copy link

github-actions bot commented Oct 17, 2025

Messages
📖 Do not forget to update Sentry-docs with your feature once the pull request gets approved.

Generated by 🚫 dangerJS against 554bf46

vaind and others added 6 commits October 17, 2025 11:18
…_VERSION

Simplifies the code by reusing the existing SENTRY_VERSION_BASE variable
which already contains the major.minor.patch format without build metadata.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
Optimizes the logic to check SENTRY_BUILD_ID cache variable first.
Only attempts to extract build ID from version string if not explicitly provided.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
Cleaner and more readable conditional structure.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
According to semver.org spec, build metadata must contain only ASCII
alphanumerics and hyphens [0-9A-Za-z-]. Spaces are not allowed.

Changed from: "2025-10-17 10:59:00 UTC"
Changed to: "20251017-105900"

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
@vaind
Copy link
Contributor Author

vaind commented Oct 17, 2025

@sentry review

@seer-by-sentry
Copy link

Seer had some issues with your request. Please try again.

@vaind
Copy link
Contributor Author

vaind commented Oct 17, 2025

This is not good enough because it only sets the right values on the second cmake configure invocation (i.e. when the sentry.h has been patched). Instead, I think we'll need to provide a way to override the sdk version

@vaind vaind closed this Oct 17, 2025
@vaind vaind deleted the feat/auto-split-build-id-from-version branch October 17, 2025 13:16
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.

2 participants