fix(sentry_apps): Prevent MissingSchema with empty webhook_url#119122
Open
sentry[bot] wants to merge 1 commit into
Open
fix(sentry_apps): Prevent MissingSchema with empty webhook_url#119122sentry[bot] wants to merge 1 commit into
sentry[bot] wants to merge 1 commit into
Conversation
Comment on lines
+257
to
+258
| if not url: | ||
| return Response() |
Contributor
Author
There was a problem hiding this comment.
Bug: The early return for an empty webhook_url incorrectly logs a configuration error as a SUCCESS in metrics because lifecycle.record_halt() is not called before exiting.
Severity: MEDIUM
Suggested Fix
Before the return Response() statement for an empty url, add a call to lifecycle.record_halt() to ensure the event lifecycle correctly records the interaction as halted due to a configuration issue, rather than incorrectly logging it as a success.
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/utils/sentry_apps/webhooks.py#L257-L258
Potential issue: When a `SentryApp` has an empty `webhook_url`, the function returns
early. This happens inside a `SentryAppInteractionEvent.capture()` context manager which
defaults to `assume_success=True`. Because the function exits cleanly without an
explicit call to `lifecycle.record_halt()`, the event is incorrectly recorded as a
`SUCCESS` in metrics. This corrupts SLO tracking by treating a configuration failure as
a successful interaction, making it harder to detect misconfigured webhooks.
Did we get this right? 👍 / 👎 to inform future reviews.
Christinarlong
approved these changes
Jul 7, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR addresses issue SENTRY-5HAE, where
send_and_save_webhook_requestwould fail with aMissingSchema: Invalid URL '': No scheme suppliederror.The root cause was that if a
SentryApphad itswebhook_urlstored as an empty string ("") instead ofNone, theurl = url or sentry_app.webhook_urlassignment would result inurlbeing"". The subsequentassert url is not Nonecheck would pass, leading tosafe_urlopen("")being called, which then raised theMissingSchemaerror.To fix this, a check
if not url: return Response()has been added immediately after the URL assignment. This ensures that if the resolved URL is an empty string (orNone, though that case was already implicitly handled by theoroperator), the webhook request is gracefully skipped, preventing the invalid HTTP call. The redundantassert url is not Nonehas also been removed.Legal Boilerplate
Look, I get it. The entity doing business as "Sentry" was incorporated in the State of Delaware in 2015 as Functional Software, Inc. and is gonna need some rights from me in order to utilize my contributions in this here PR. So here's the deal: I retain all rights, title and interest in and to my contributions, and by keeping this boilerplate intact I confirm that Sentry can use, modify, copy, and redistribute my contributions, under Sentry's choice of terms.
Fixes SENTRY-5HAE
Comment
@sentry <feedback>on this PR to have Autofix iterate on the changes.