From 0c1e82d218265e5274dad912c08b2fbdf4c3d24a Mon Sep 17 00:00:00 2001 From: Betty Da Date: Thu, 4 Nov 2021 01:35:07 -0400 Subject: [PATCH 1/2] fix(appstore-connect): Return more detailed errors when API credentials are unusable --- .../api/endpoints/project_app_store_connect_credentials.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/sentry/api/endpoints/project_app_store_connect_credentials.py b/src/sentry/api/endpoints/project_app_store_connect_credentials.py index 3bd22b63f18841..9eac489a4b6d65 100644 --- a/src/sentry/api/endpoints/project_app_store_connect_credentials.py +++ b/src/sentry/api/endpoints/project_app_store_connect_credentials.py @@ -154,7 +154,12 @@ def post(self, request: Request, project: Project) -> Response: ) session = requests.Session() - apps = appstore_connect.get_apps(session, credentials) + try: + apps = appstore_connect.get_apps(session, credentials) + except appstore_connect.UnauthorizedError: + raise AppConnectAuthenticationError() + except appstore_connect.ForbiddenError: + raise AppConnectForbiddenError() if apps is None: raise AppConnectAuthenticationError() From e2a683a8f3f091cd25314c02bd189f73d7d831a9 Mon Sep 17 00:00:00 2001 From: Betty Da Date: Fri, 5 Nov 2021 14:00:52 -0400 Subject: [PATCH 2/2] remove no-op instantiation --- .../api/endpoints/project_app_store_connect_credentials.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/sentry/api/endpoints/project_app_store_connect_credentials.py b/src/sentry/api/endpoints/project_app_store_connect_credentials.py index 9eac489a4b6d65..7908c1270fdb68 100644 --- a/src/sentry/api/endpoints/project_app_store_connect_credentials.py +++ b/src/sentry/api/endpoints/project_app_store_connect_credentials.py @@ -157,12 +157,12 @@ def post(self, request: Request, project: Project) -> Response: try: apps = appstore_connect.get_apps(session, credentials) except appstore_connect.UnauthorizedError: - raise AppConnectAuthenticationError() + raise AppConnectAuthenticationError except appstore_connect.ForbiddenError: - raise AppConnectForbiddenError() + raise AppConnectForbiddenError if apps is None: - raise AppConnectAuthenticationError() + raise AppConnectAuthenticationError all_apps = [ {"name": app.name, "bundleId": app.bundle_id, "appId": app.app_id} for app in apps