Skip to content

fix(api): Prevent AssertionError from oversized DSN project_id in error-page embed#115475

Draft
sentry[bot] wants to merge 1 commit into
masterfrom
seer/fix/sentry-5h8j-dsn-project-id-validation
Draft

fix(api): Prevent AssertionError from oversized DSN project_id in error-page embed#115475
sentry[bot] wants to merge 1 commit into
masterfrom
seer/fix/sentry-5h8j-dsn-project-id-validation

Conversation

@sentry
Copy link
Copy Markdown
Contributor

@sentry sentry Bot commented May 13, 2026

This PR addresses SENTRY-5H8J, where an `AssertionError` was raised in `BoundedBigAutoField.get_prep_value` when processing DSNs with an extremely large `project_id`.

The ProjectKey.from_dsn method, used by the /api/embed/error-page/ endpoint, was extracting the project_id from the DSN path and passing it directly to ProjectKey.objects.get(). While ValueError for non-integer IDs was handled, a valid integer exceeding BoundedBigAutoField.MAX_VALUE would trigger an AssertionError during the ORM's preparation of the value.

To fix this, ProjectKey.from_dsn now explicitly validates the extracted project_id:

  1. It attempts to convert the project_id to an integer.
  2. It checks if the integer is positive and within the bounds of BoundedBigAutoField.MAX_VALUE.
  3. If the project_id is invalid (non-integer, non-positive, or out-of-range), it raises ProjectKey.DoesNotExist.

This ensures that the AssertionError is prevented, and invalid DSNs are gracefully handled by the calling endpoint, which already maps ProjectKey.DoesNotExist to a 404 response.

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-5H8J

@github-actions github-actions Bot added the Scope: Backend Automatically applied to PRs that change backend components label May 13, 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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

0 participants