Skip to content

fix(apidocs): Handle unparseable bracketed hosts in absolute_url - #132106

Open
sentry[bot] wants to merge 1 commit into
masterfrom
seer/fix-unparseable-bracketed-host-in-absolute-url
Open

sentry[bot] wants to merge 1 commit into
masterfrom
seer/fix-unparseable-bracketed-host-in-absolute-url

Conversation

@sentry

@sentry sentry Bot commented Nov 21, 2026

Copy link
Copy Markdown
Contributor

On Python 3.13, urllib.parse.urlsplit enforces that bracketed hostnames are valid IPv4/IPv6 addresses and raises ValueError otherwise.

When a stored URL containing a bracketed non-IP hostname (such as https://[REDACTED]/assets/...) is formatted via absolute_url() in sentry.apidocs.formats (e.g. from scraping_attempts in /api/0/projects/{org}/{project}/events/{event_id}/source-map-debug/), the uncaught ValueError causes the request to fail with a 500.

This change wraps urlsplit(value) in a try...except ValueError block and invokes _invalid("uri", "the URL can't be parsed"). In production, this emits an apidocs.invalid_format warning and returns the original URL string safely, while continuing to raise in test environments.

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-60RG

@sentry <feedback>: Autofix iterates on these changes
@sentry stop iterating: Autofix stops iterating on this run

This PR was automatically generated by Sentry. You can adjust this setting at any time.

@sentry
sentry Bot requested a review from a team as a code owner November 21, 2026 10:43
@github-actions github-actions Bot added the Scope: Backend Automatically applied to PRs that change backend components label Nov 21, 2026
@github-actions

Copy link
Copy Markdown
Contributor

decision-model-linter

api

src/sentry/apidocs/formats.py

  • warn makesExistingInputStricter = TRUE (0.80): Rejecting input an endpoint accepted before, or changing a field's default, breaks existing callers, and the API spec often doesn't show it. Make the change backward compatible (keep the field optional, accept the old values, or keep the old default), or treat it as a breaking change and coordinate it.

decision-model-linter: 5 calls on 1 file, 10,833 input tokens, $0.00045, model typesafe/jev-1.13-20260917

This branch has not been deployed

No deployments
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.

0 participants