Skip to content

fix(sentry-apps): Handle empty webhook_url in external requests#109529

Merged
GabeVillalobos merged 3 commits intomasterfrom
seer/fix-sentry-app-empty-webhook-url
Mar 2, 2026
Merged

fix(sentry-apps): Handle empty webhook_url in external requests#109529
GabeVillalobos merged 3 commits intomasterfrom
seer/fix-sentry-app-empty-webhook-url

Conversation

@sentry
Copy link
Contributor

@sentry sentry bot commented Feb 26, 2026

This PR fixes the MissingSchema error that occurred when Sentry App external requests were made with an empty webhook_url.

Root Cause:
The urlparse() function, when given an empty string (''), returns a ParseResult with all components (scheme, netloc, path) empty. When subsequent URL building logic (e.g., in SelectRequester._build_url()) then attempts to construct a URL by replacing only the path or netloc, it results in a relative URL (e.g., /sentry/issues?...) that lacks a scheme. The requests library, used by safe_urlopen, then rejects this malformed URL with a MissingSchema exception.

Fix:
Early validation has been added to the _build_url() methods in SelectRequester, AlertRuleActionRequester, IssueLinkRequester, and the _prepare_stacktrace_link() method in components.py. These checks now explicitly raise a SentryAppIntegratorError if self.sentry_app.webhook_url is empty or None. This ensures that:

  • The error is caught before a malformed URL is passed to the requests library.
  • A more descriptive SentryAppIntegratorError is raised, providing clearer context (e.g., MISSING_URL) to the user and for internal logging, instead of the generic MissingSchema.
  • The existing error handling mechanisms in the respective run() methods can gracefully process this specific error type.

Affected Files:

  • src/sentry/sentry_apps/external_requests/select_requester.py
  • src/sentry/sentry_apps/external_requests/alert_rule_action_requester.py
  • src/sentry/sentry_apps/external_requests/issue_link_requester.py
  • src/sentry/sentry_apps/components.py

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.

@github-actions github-actions bot added the Scope: Backend Automatically applied to PRs that change backend components label Feb 26, 2026
@sentry sentry bot force-pushed the seer/fix-sentry-app-empty-webhook-url branch from e797c3b to a0b0c0b Compare February 26, 2026 22:50
@sentry sentry bot changed the title fix(sentry-apps): Handle empty webhook_url to prevent MissingSchema fix(sentry-apps): Handle empty webhook_url in external requests Feb 26, 2026
@GabeVillalobos GabeVillalobos added the Trigger: getsentry tests Once code is reviewed: apply label to PR to trigger getsentry tests label Mar 2, 2026
@GabeVillalobos GabeVillalobos marked this pull request as ready for review March 2, 2026 17:09
@GabeVillalobos GabeVillalobos requested review from a team as code owners March 2, 2026 17:09
@GabeVillalobos GabeVillalobos merged commit bbe1145 into master Mar 2, 2026
77 of 80 checks passed
@GabeVillalobos GabeVillalobos deleted the seer/fix-sentry-app-empty-webhook-url branch March 2, 2026 20:03
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.

2 participants