From 517ba99be74563f3a60092fff3c86a8762e28cba Mon Sep 17 00:00:00 2001 From: jasquat Date: Fri, 16 Dec 2022 13:23:59 -0500 Subject: [PATCH] Squashed 'flask-bpmn/' changes from 53051e39..0f2d249d 0f2d249d added new api endpoint to get task-info so users with access to process instances can see the tasks but not the data git-subtree-dir: flask-bpmn git-subtree-split: 0f2d249d0e799bec912d46132e9ef9754fdacbd7 --- src/flask_bpmn/api/api_error.py | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/src/flask_bpmn/api/api_error.py b/src/flask_bpmn/api/api_error.py index eb390abe..c782c2d3 100644 --- a/src/flask_bpmn/api/api_error.py +++ b/src/flask_bpmn/api/api_error.py @@ -170,15 +170,17 @@ def set_user_sentry_context() -> None: def handle_exception(exception: Exception) -> flask.wrappers.Response: """Handles unexpected exceptions.""" set_user_sentry_context() - id = capture_exception(exception) - organization_slug = current_app.config.get("SENTRY_ORGANIZATION_SLUG") - project_slug = current_app.config.get("SENTRY_PROJECT_SLUG") sentry_link = None - if organization_slug and project_slug: - sentry_link = ( - f"https://sentry.io/{organization_slug}/{project_slug}/events/{id}" - ) + if not isinstance(exception, ApiError) or exception.error_code != "invalid_token": + id = capture_exception(exception) + + organization_slug = current_app.config.get("SENTRY_ORGANIZATION_SLUG") + project_slug = current_app.config.get("SENTRY_PROJECT_SLUG") + if organization_slug and project_slug: + sentry_link = ( + f"https://sentry.io/{organization_slug}/{project_slug}/events/{id}" + ) # !!!NOTE!!!: do this after sentry stuff since calling logger.exception # seems to break the sentry sdk context where we no longer get back