Skip to content

feat(sentry): send a valid release per commit - #140

Open
olivermeyer wants to merge 3 commits into
mainfrom
feat/VPTHP-234-sentry-release
Open

olivermeyer wants to merge 3 commits into
mainfrom
feat/VPTHP-234-sentry-release

Conversation

@olivermeyer

@olivermeyer olivermeyer commented Nov 3, 2026 •

Copy link
Copy Markdown
Collaborator

Why?
Sentry drops the release that foundry-core sends, because version_full contains / in prod builds. Without a valid release, a commit with Fixes PVIZ-… cannot resolve an issue in a release, and a later event does not mark the issue "regressed". Jira: VPTHP-234.

How?
FoundryContext gets a commit_sha field from COMMIT_SHA, and sentry_initialize sends the release <name>@<version>+<commit_sha>. CI can build the same name with sentry-cli to link commits. If the name contains / or \ or has more than 200 characters, foundry-core drops the SHA suffix and logs a warning.

🤖 Generated with Claude Code

olivermeyer and others added 3 commits November 3, 2026 13:46
Read COMMIT_SHA in from_package and pass it to both version helpers.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Read COMMIT_SHA into the new commit_sha field. The value is None when the variable is unset, empty or blank.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Send the release <name>@<version>+<commit_sha>. The old release used version_full, which can contain '/'. Sentry drops such a release. Drop the SHA suffix and log a warning if the name is not valid.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@ox-security

ox-security Bot commented Nov 3, 2026

Copy link
Copy Markdown

OX Security Logo

OX Security reviewed this pull request — nothing to fix.

✔ No issues found

Branch feat/VPTHP-234-sentry-release → main

View scan in OX Security →

@codecov

codecov Bot commented Nov 3, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ All tests successful. No failed tests found.

Files with missing lines Coverage Δ
src/aignostics_foundry_core/foundry.py 97.56% <100.00%> (+0.01%) ⬆️
src/aignostics_foundry_core/sentry.py 93.93% <100.00%> (+0.55%) ⬆️

@sonarqubecloud

sonarqubecloud Bot commented Nov 3, 2026

Copy link
Copy Markdown

@olivermeyer
olivermeyer marked this pull request as ready for review November 3, 2026 14:04
@olivermeyer
olivermeyer requested a review from a team as a code owner November 3, 2026 14:04
Comment on lines +212 to +214
version_full=_build_version_full(version, vcs_ref, commit_sha),
version_with_vcs_ref=_build_version_with_vcs_ref(version, vcs_ref, commit_sha),
commit_sha=None if commit_sha == "unknown" else (commit_sha.strip() or None),

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

One line is enough. The Dockerfile template sets ARG COMMIT_SHA="", never unknown. With this change, drop the commit_sha local above and put both _build_version_* helpers back to their main versions.

Suggested change
version_full=_build_version_full(version, vcs_ref, commit_sha),
version_with_vcs_ref=_build_version_with_vcs_ref(version, vcs_ref, commit_sha),
commit_sha=None if commit_sha == "unknown" else (commit_sha.strip() or None),
version_full=_build_version_full(version, vcs_ref),
version_with_vcs_ref=_build_version_with_vcs_ref(version, vcs_ref),
commit_sha=os.getenv("COMMIT_SHA", "").strip() or None,


sentry_sdk.init(
release=f"{ctx.name}@{ctx.version_full}",
release=_release_name(ctx),

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Inline it, and delete _release_name and its constants. The package name, a PEP 440 version and ${{ github.sha }} can't contain / or \, and together they stay far below 200 characters. The guard only catches a hand-set COMMIT_SHA.

Tests: ..._drops_invalid_commit_sha goes with the guard. ..._valid_with_full_build_metadata repeats ..._has_commit_sha, which already fails if the release goes back to {name}@{version_full}. Dropping it also removes version_full from make_context.

Suggested change
release=_release_name(ctx),
release=f"{ctx.name}@{ctx.version}" + (f"+{ctx.commit_sha}" if ctx.commit_sha else ""),

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