Skip to content

fix(preprod): Add organization_slug to snapshot log statements#112499

Merged
NicoHinderling merged 2 commits intomasterfrom
nh/add-org-slug-to-preprod-logs
Apr 8, 2026
Merged

fix(preprod): Add organization_slug to snapshot log statements#112499
NicoHinderling merged 2 commits intomasterfrom
nh/add-org-slug-to-preprod-logs

Conversation

@NicoHinderling
Copy link
Copy Markdown
Contributor

@NicoHinderling NicoHinderling commented Apr 8, 2026

Summary

  • Adds organization_slug to 4 preprod snapshot log statements for easier filtering by organization in logging dashboards
  • Replaces organization_id with organization_slug in the snapshot creation log
  • Adds organization_slug to auto-approve, comparison complete, and comparison failed logs

doing this for our sentry dashboard usage

Adds organization_slug to key preprod snapshot log statements for
easier filtering by organization in logging dashboards.
@NicoHinderling NicoHinderling requested a review from a team as a code owner April 8, 2026 18:52
@github-actions github-actions bot added the Scope: Backend Automatically applied to PRs that change backend components label Apr 8, 2026
Copy link
Copy Markdown
Contributor

@cursor cursor bot left a comment

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit a12d0f8. Configure here.

Comment thread src/sentry/preprod/snapshots/tasks.py
extra={
"head_artifact_id": head_artifact_id,
"base_artifact_id": base_artifact_id,
"organization_slug": head_artifact.project.organization.slug,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Bug: Accessing head_artifact in the generic exception handler can cause a NameError if it was never assigned, masking the original error.
Severity: MEDIUM

Suggested Fix

Initialize head_artifact to None before the try block. In the exception handler, conditionally access head_artifact.project.organization.slug only if head_artifact is not None to prevent the NameError.

Prompt for AI Agent
Review the code at the location below. A potential bug has been identified by an AI
agent.
Verify if this is a real issue. If it is, propose a fix; if not, explain why it's not
valid.

Location: src/sentry/preprod/snapshots/tasks.py#L742

Potential issue: In the outer `except BaseException:` block, the code accesses
`head_artifact` to log the organization slug. However, if an exception other than
`PreprodArtifact.DoesNotExist` (such as a `DatabaseError` or `TimeoutError`) occurs when
initially fetching `head_artifact`, the variable will not be defined. This will cause a
`NameError` inside the exception handler, which masks the original, more informative
exception and prevents proper error logging and debugging.

Did we get this right? 👍 / 👎 to inform future reviews.

@NicoHinderling NicoHinderling merged commit 372b405 into master Apr 8, 2026
56 checks passed
@NicoHinderling NicoHinderling deleted the nh/add-org-slug-to-preprod-logs branch April 8, 2026 19:46
george-sentry pushed a commit that referenced this pull request Apr 9, 2026
## Summary
- Adds `organization_slug` to 4 preprod snapshot log statements for
easier filtering by organization in logging dashboards
- Replaces `organization_id` with `organization_slug` in the snapshot
creation log
- Adds `organization_slug` to auto-approve, comparison complete, and
comparison failed logs


doing this for our sentry dashboard usage
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Scope: Backend Automatically applied to PRs that change backend components

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants