Skip to content

Conversation

@rbro112
Copy link
Member

@rbro112 rbro112 commented Nov 5, 2025

Had a recent upload fail to process due to a hang. We never received an alert directly from the point of the hang (separate issue), but we do have a fallthrough to catch hanging artifacts. This wires up a custom message which will create an issue for each hung artifact we catch.

Resolves EME-600

@rbro112 rbro112 requested a review from a team as a code owner November 5, 2025 19:17
Copy link
Member Author

rbro112 commented Nov 5, 2025

This stack of pull requests is managed by Graphite. Learn more about stacking.

@github-actions github-actions bot added the Scope: Backend Automatically applied to PRs that change backend components label Nov 5, 2025
@rbro112 rbro112 changed the title Alert to Sentry on PreprodArtifact expiration chore(preprod): Alert to Sentry on PreprodArtifact expiration Nov 5, 2025
Comment on lines 645 to 651
sentry_sdk.capture_message(
f"PreprodArtifact expired: artifact_id={artifact_id}",
level="error",
extras={
"artifact_id": artifact_id,
},
)
Copy link

Choose a reason for hiding this comment

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

Bug: sentry_sdk.capture_message() is called with an unsupported extras= keyword argument, leading to a TypeError.
Severity: HIGH | Confidence: 1.00

🔍 Detailed Analysis

The sentry_sdk.capture_message() function is invoked with an unsupported extras= keyword argument. This occurs within the detect_expired_preprod_artifacts() task when expired artifacts are identified and a Sentry message is attempted. The invocation will raise a TypeError at runtime, causing the task to crash and preventing the Sentry alert for expired artifacts from being sent. This hinders monitoring of artifact expiration issues.

💡 Suggested Fix

Remove the extras= parameter from the sentry_sdk.capture_message() call. Instead, use sentry_sdk.get_current_scope().set_extra("artifact_id", artifact_id) before calling capture_message() to attach extra data.

🤖 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/tasks.py#L645-L651

Potential issue: The `sentry_sdk.capture_message()` function is invoked with an
unsupported `extras=` keyword argument. This occurs within the
`detect_expired_preprod_artifacts()` task when expired artifacts are identified and a
Sentry message is attempted. The invocation will raise a `TypeError` at runtime, causing
the task to crash and preventing the Sentry alert for expired artifacts from being sent.
This hinders monitoring of artifact expiration issues.

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

Copy link
Member Author

Choose a reason for hiding this comment

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

This will be passed as scope_kwargs and per the docs in the internal SDK calls, is both supported and will be just appended to the message:

:param scope_kwargs: Optional data to apply to event.
            For supported `**scope_kwargs` see :py:meth:`sentry_sdk.Scope.update_from_kwargs`.
            The `scope` and `scope_kwargs` parameters are mutually exclusive.
Screenshot 2025-11-05 at 11 34 07 AM

@linear
Copy link

linear bot commented Nov 5, 2025

@rbro112 rbro112 merged commit ac3b35a into master Nov 5, 2025
65 checks passed
@rbro112 rbro112 deleted the ryan/alert_to_sentry_on_preprodartifact_expiration branch November 5, 2025 22:43
priscilawebdev pushed a commit that referenced this pull request Nov 6, 2025
Had a recent upload fail to process due to a hang. We never received an
alert directly from the point of the hang (separate issue), but we do
have a fallthrough to catch hanging artifacts. This wires up a [custom
message](https://docs.sentry.io/platforms/python/usage/#capturing-messages)
which will create an issue for each hung artifact we catch.

Resolves EME-600
Ahmed-Labs pushed a commit that referenced this pull request Nov 6, 2025
Had a recent upload fail to process due to a hang. We never received an
alert directly from the point of the hang (separate issue), but we do
have a fallthrough to catch hanging artifacts. This wires up a [custom
message](https://docs.sentry.io/platforms/python/usage/#capturing-messages)
which will create an issue for each hung artifact we catch.

Resolves EME-600
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.

3 participants