Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Graceful handling of preview input errors #1271

Closed
torgeirl opened this issue Aug 24, 2023 · 1 comment
Closed

Graceful handling of preview input errors #1271

torgeirl opened this issue Aug 24, 2023 · 1 comment
Assignees
Labels

Comments

@torgeirl
Copy link
Collaborator

torgeirl commented Aug 24, 2023

Similar to #1228, ValueError from /devilry_comment/_api/preview-markdown (comment message previews failing due to syntax errors in code/markdown input) doesn't provide any actionable data.

From the user's perspective it is handled well, but from the system side this error is unnecessary and shouldn't be generated.

@torgeirl torgeirl added this to the Devilry 6.1 milestone Aug 24, 2023
@torgeirl torgeirl self-assigned this Aug 24, 2023
@torgeirl
Copy link
Collaborator Author

(...) from the system side this error is unnecessary and shouldn't be generated.

Fixed by preventing the exception from being forwarded to Sentry with before_send filtering:

from urllib.parse import urlparse
from sentry_sdk import init as sentry_init

(...)

def before_send(event, hint):
    '''Ignore errors caused by faulty preview input.'''
    url_string = event['request']['url']
    parsed_url = urlparse(url_string)

    if parsed_url.path == '/devilry_comment/_api/preview-markdown':
        if 'exc_info' in hint:
            exc_type, exc_value, tb = hint['exc_info']
            if isinstance(exc_value, ValueError):
                return None
    return event

(...)

sentry_init(
    (...)
    before_send=before_send,
    (...)

@torgeirl torgeirl removed this from the Devilry 6.1 milestone Aug 29, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant