feat(preprod): Add git metadata and artifact IDs as tags for size analysis issues#110854
feat(preprod): Add git metadata and artifact IDs as tags for size analysis issues#110854
Conversation
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 2 potential issues.
Autofix Details
Bugbot Autofix prepared fixes for both issues found in the latest run.
- ✅ Fixed: Nullable
head_refused unconditionally as tag value- I guarded the branch tag assignment so
head_refis only added when non-null, preventingNonevalues in the string tag map.
- I guarded the branch tag assignment so
- ✅ Fixed: Missing
select_relatedforcommit_comparisonin manual task- I added
select_related("preprod_artifact__commit_comparison")to both manual comparison metric querysets to avoid per-artifact lazy loads.
- I added
Or push these changes by commenting:
@cursor push 067ecdfead
Preview (067ecdfead)
diff --git a/src/sentry/preprod/size_analysis/grouptype.py b/src/sentry/preprod/size_analysis/grouptype.py
--- a/src/sentry/preprod/size_analysis/grouptype.py
+++ b/src/sentry/preprod/size_analysis/grouptype.py
@@ -61,7 +61,8 @@
commit_comparison = artifact.commit_comparison
if commit_comparison is not None:
tags["commit_sha"] = commit_comparison.head_sha
- tags["branch"] = commit_comparison.head_ref
+ if commit_comparison.head_ref is not None:
+ tags["branch"] = commit_comparison.head_ref
tags["repo"] = commit_comparison.head_repo_name
if commit_comparison.base_sha:
tags["base_sha"] = commit_comparison.base_sha
diff --git a/src/sentry/preprod/size_analysis/tasks.py b/src/sentry/preprod/size_analysis/tasks.py
--- a/src/sentry/preprod/size_analysis/tasks.py
+++ b/src/sentry/preprod/size_analysis/tasks.py
@@ -326,6 +326,7 @@
)
.select_related("preprod_artifact")
.select_related("preprod_artifact__mobile_app_info")
+ .select_related("preprod_artifact__commit_comparison")
)
head_size_metrics = list(head_size_metrics_qs)
@@ -337,6 +338,7 @@
)
.select_related("preprod_artifact")
.select_related("preprod_artifact__mobile_app_info")
+ .select_related("preprod_artifact__commit_comparison")
)
base_size_metrics = list(base_size_metrics_qs)This Bugbot Autofix run was free. To enable autofix for future PRs, go to the Cursor dashboard.
Backend Test FailuresFailures on
|
265a229 to
6e8a3ab
Compare
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Backend Test FailuresFailures on
|
|
|
||
|
|
||
| def _artifact_to_tags(artifact: PreprodArtifact) -> dict[str, str]: | ||
| def _artifact_to_tags(artifact: PreprodArtifact, *, include_git: bool = True) -> dict[str, str]: |
There was a problem hiding this comment.
this get's called twice, once for head and once for base build:
You might want to add this below: https://github.com/getsentry/sentry/pull/110854/changes#diff-be91e49fb005a5e8d892931306474bc033bd1af21bb40c5a929f89562ea6742eR246
(so it appears at the root level)
There was a problem hiding this comment.
oh I see it's controlled via the include_git boolean. I still would not put this here even if you want it nested under head. You could just directly add the tags below and name them head.foo
…lysis issues Emit commit SHA, branch, repo, base SHA, base branch, PR number, provider, and artifact ID as tags on size analysis issue events so they are searchable and filterable in the issue detail page. Also add select_related for commit_comparison in the size analysis task queries to avoid N+1 queries when building tags. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Rename commit_sha to sha so it renders cleanly as "sha" under the head/base tag groups. Drop provider tag as unnecessary. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…ual task The manual_size_analysis_comparison task querysets were not updated with the commit_comparison select_related, causing N+1 queries. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
The head artifact's commit_comparison already contains the base SHA and base branch, so emitting git tags for the base artifact is redundant and potentially confusing. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Git metadata describes the comparison context, not a specific artifact, so it belongs at the root level rather than nested under head.*. This produces a cleaner tag layout: head.*/base.* for artifact-level tags and git.* for commit comparison metadata. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
a99f163 to
b57bbb9
Compare
… git tags Mypy cannot narrow Django model field types through truthiness checks. Use walrus operator with `is not None` to properly narrow nullable string fields from CommitComparison. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Make `head.artifact_id` and `base.artifact_id` tags clickable on the
issue detail page, linking to the preprod size build detail page
(`/preprod/size/{id}/`).
These tags were added in #110854 but rendered as plain text. This adds
them to the existing tag-key switch in `EventTagsTreeValue`, following
the same `Link` + `TagLinkText` pattern used by `transaction` and
`replayId` tags. Uses the existing `getSizeBuildPath` utility.
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>


Summary
_artifact_to_tags()to emitartifact_id,commit_sha,branch,repo,base_sha,base_branch,pr_numberas tags on size analysis issue eventsselect_related("preprod_artifact__commit_comparison")to 4 queryset calls in the comparison task to avoid N+1 queriesTest plan
pytest -svv --create-db tests/sentry/preprod/size_analysis/test_grouptype.py— all 23 tests passpre-commit run --fileson all modified files passes