Browse Source

chore(hc): Handles sentry app permission check where org is not found (#69175)

Gabe Villalobos 10 months ago
parent
commit
a959af6053
1 changed files with 13 additions and 0 deletions
  1. 13 0
      src/sentry/api/bases/sentryapps.py

+ 13 - 0
src/sentry/api/bases/sentryapps.py

@@ -1,5 +1,6 @@
 from __future__ import annotations
 
+import logging
 from functools import wraps
 from typing import Any
 
@@ -33,6 +34,8 @@ from sentry.utils.strings import to_single_line_str
 
 COMPONENT_TYPES = ["stacktrace-link", "issue-link"]
 
+logger = logging.getLogger(__name__)
+
 
 def catch_raised_errors(func):
     @wraps(func)
@@ -487,6 +490,16 @@ class SentryAppStatsPermission(SentryPermission):
         owner_app = organization_service.get_organization_by_id(
             id=sentry_app.owner_id, user_id=request.user.id
         )
+        if owner_app is None:
+            logger.error(
+                "sentry_app_stats.permission_org_not_found",
+                extra={
+                    "sentry_app_id": sentry_app.id,
+                    "owner_org_id": sentry_app.owner_id,
+                    "user_id": request.user.id,
+                },
+            )
+            return False
         self.determine_access(request, owner_app)
 
         if is_active_superuser(request):