Skip to content

fix(sentry_apps): Prevent MissingSchema with empty webhook_url#119122

Open
sentry[bot] wants to merge 1 commit into
masterfrom
seer/fix/sentry-app-empty-webhook-url
Open

fix(sentry_apps): Prevent MissingSchema with empty webhook_url#119122
sentry[bot] wants to merge 1 commit into
masterfrom
seer/fix/sentry-app-empty-webhook-url

Conversation

@sentry

@sentry sentry Bot commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

This PR addresses issue SENTRY-5HAE, where send_and_save_webhook_request would fail with a MissingSchema: Invalid URL '': No scheme supplied error.

The root cause was that if a SentryApp had its webhook_url stored as an empty string ("") instead of None, the url = url or sentry_app.webhook_url assignment would result in url being "". The subsequent assert url is not None check would pass, leading to safe_urlopen("") being called, which then raised the MissingSchema error.

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 (or None, though that case was already implicitly handled by the or operator), the webhook request is gracefully skipped, preventing the invalid HTTP call. The redundant assert url is not None has 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.

@github-actions github-actions Bot added the Scope: Backend Automatically applied to PRs that change backend components label Jul 7, 2026
Comment on lines +257 to +258
if not url:
return Response()

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

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 Christinarlong added the Trigger: getsentry tests Once code is reviewed: apply label to PR to trigger getsentry tests label Jul 7, 2026
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 Trigger: getsentry tests Once code is reviewed: apply label to PR to trigger getsentry tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant