Repository navigation
feat(sentry): send a valid release per commit - #140
olivermeyer wants to merge 3 commits into
Conversation
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 reviewed this pull request — nothing to fix.
Branch |
Codecov Report✅ All modified and coverable lines are covered by tests.
|
|
| 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), |
There was a problem hiding this comment.
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.
| 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), |
There was a problem hiding this comment.
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.
| release=_release_name(ctx), | |
| release=f"{ctx.name}@{ctx.version}" + (f"+{ctx.commit_sha}" if ctx.commit_sha else ""), |



Why?
Sentry drops the release that foundry-core sends, because
version_fullcontains/in prod builds. Without a valid release, a commit withFixes PVIZ-…cannot resolve an issue in a release, and a later event does not mark the issue "regressed". Jira: VPTHP-234.How?
FoundryContextgets acommit_shafield fromCOMMIT_SHA, andsentry_initializesends the release<name>@<version>+<commit_sha>. CI can build the same name withsentry-clito 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