Skip to content

Bug: Sentry provider validate_scopes crashes on empty response body from /plugins/webhooks/ #6812

Description

@apercivall

Description

Clicking "Validate Scopes" on the Sentry provider fails with "Failed to revalidate scopes". All scopes show "Not checked" even though the provider is connected and pulling alerts successfully.

Root Cause

In sentry_provider.py line ~208, the project:write scope validation sends a POST to:

{sentry_api}/projects/{org}/{project}/plugins/webhooks/

Sentry returns 404 with an empty HTML body (Content-Type: text/html, body length: 0). This is likely because the legacy plugins API has been deprecated.

The code then calls response.json() without checking for an empty body:

if not response.ok:
    response_json = response.json()  # JSONDecodeError: empty body

The exception is unhandled, so it propagates up and kills the entire validation — causing ALL scopes to show "Not checked", not just project:write.

Suggested Fix

if not response.ok:
    try:
        response_json = response.json()
        validated_scopes[scope.name] = response_json.get("detail")
    except (requests.exceptions.JSONDecodeError, ValueError):
        validated_scopes[scope.name] = f"HTTP {response.status_code}"
    continue

This pattern should be applied to all scope checks in validate_scopes (event:read, project:read, project:write).

Additionally, the /plugins/webhooks/ endpoint may need updating since Sentry has been deprecating the legacy plugin system.

Environment

  • Keep version: 0.54.3
  • Sentry: SaaS (sentry.io)
  • Provider mode: Pull (60-min interval)
  • Provider status: Connected, pulling alerts successfully

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions