Skip to content

Commit a8c75ed

Browse files
committed
fix typing issues
1 parent 2e4aa9c commit a8c75ed

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

src/sentry/api/endpoints/integrations/sentry_apps/rotate_secret.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,13 @@ class SentryAppRotateSecretPermission(SentryPermission):
2121

2222
def has_object_permission(self, request: Request, view: object, sentry_app: SentryApp):
2323
# organization that owns an integration
24-
organization = organization_service.get_org_by_id(id=sentry_app.owner_id)
24+
org_context = organization_service.get_organization_by_id(id=sentry_app.owner_id)
25+
if org_context is None:
26+
raise Http404
27+
28+
organization = org_context.organization
29+
if organization is None:
30+
raise Http404
2531

2632
# if user is not a member of an organization owning an integration,
2733
# return 404 to avoid leaking integration slug
@@ -48,6 +54,9 @@ class SentryAppRotateSecretEndpoint(SentryAppBaseEndpoint):
4854
permission_classes = (SentryAppRotateSecretPermission,)
4955

5056
def post(self, request: Request, sentry_app: SentryApp) -> Response:
57+
if sentry_app.application is None:
58+
return Response(status=404)
59+
5160
new_token = generate_token()
5261
sentry_app.application.update(client_secret=new_token)
5362
return Response(serialize({"clientSecret": new_token}))

0 commit comments

Comments
 (0)