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

Log Recaptcha errors in Sentry #10476

Merged

Conversation

jimchamp
Copy link
Collaborator

Closes #10474

Captures the error-codes field of any failing ReCaptcha verification in Sentry.

Technical

Testing

Screenshot

Stakeholders

@github-actions github-actions bot added the Priority: 1 Do this week, receiving emails, time sensitive, . [managed] label Feb 19, 2025
Copy link
Collaborator

@cdrini cdrini left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One question for you, I think we can just log this to have it appear in sentry

Comment on lines 39 to 43
if not data.get('success', False) and 'error-codes' in data:
from openlibrary.plugins.openlibrary.sentry import sentry

if sentry and sentry.enabled:
sentry.capture_message(f"Recaptcha Error: {data['error-codes']}")

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

logged exceptions are captured in sentry, so we should be able to do:

Suggested change
if not data.get('success', False) and 'error-codes' in data:
from openlibrary.plugins.openlibrary.sentry import sentry
if sentry and sentry.enabled:
sentry.capture_message(f"Recaptcha Error: {data['error-codes']}")
if not data.get('success', False) and 'error-codes' in data:
logging.getLogger("openlibrary").exception(f"Recaptcha Error: {data['error-codes']}")

I believe.

@jimchamp jimchamp force-pushed the 10474/bug/handle-recaptcha-errors branch from 70fd537 to d157c7e Compare February 19, 2025 01:40
Copy link
Collaborator

@cdrini cdrini left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Works like a charm!

image

@cdrini cdrini merged commit 0afb824 into internetarchive:master Feb 19, 2025
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Priority: 1 Do this week, receiving emails, time sensitive, . [managed]
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Capture/handle recaptcha service erroring
2 participants