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

MPP-3722, MPP-3513, MPP-3890, MPP-3373: Handle more errors when relaying SMS messages #5001

Merged
merged 9 commits into from
Sep 10, 2024

Conversation

jwhitlock
Copy link
Member

This PR addresses a few tickets, to remove some 500 errors from the service:

  • MPP-3722: Changes the RelaySMSException classes to be based on RelayAPIException
    • Also sets ftl_id on the exception classes, to make it easier to cross-reference exceptions to the translated versions
    • Also move exceptions to /phones/exceptions.py
    • Sync NoPhoneLog message with translations
    • Update TemplateTwiMLRenderer to handle RelaySMSException without having to wrap in rest_framework.exceptions.ValidationError
    • Skip title case for RelaySMSException, keep for ValidationError
  • MPP-3513: ShortPrefixMatchesNoSenders - Log at INFO instead of sending an exception to Sentry. This is done for all exceptions derived from RelaySMSException, for Twilio and iQ
  • MPP-3890: When the number for a previous contact can not be parsed by the phonenumbers, skip it rather than raise the exception
  • MPP-3373 (addressed but not fixed) - When a Relay user has sent STOP to their Relay number, we can't send them any more messages. Log this as INFO and reply with an empty "OK" response to Twilio. This prevents the 500 error, but doesn't help the Relay user discover the issue. An obvious next step is to set a flag on the RelayNumber or RealNumber that the user has blocked their Relay number, so we can show that in the frontend.
  • Fix some typos detected by typos

If this is too much for one PR, I can break it up.

How to test:

Instead of deriving the FTL ID from the default_code, add it explictly
to the RelayAPIException or derived class. This makes it easier to
cross-reference misc.ftl with the exceptions, and verify that a
translation is in use.
This will retain the data about users encountering SMS reply issues, but
in the logs rather than as Sentry issues.
When a Relay user replies 'STOP', they are unsubscribed from Twilio and
we can't send them any more messages.

When a contact replies 'STOP', the Relay user can't reply to them
anymore.

There are other errors, but those haven't happened to us yet. Log as
errors.
@jwhitlock jwhitlock force-pushed the refactor-relay-sms-exception-mpp3722 branch from af27798 to 95be73c Compare September 6, 2024 22:10
api/tests/phones_views_tests.py Show resolved Hide resolved
api/views/phones.py Outdated Show resolved Hide resolved
api/views/phones.py Outdated Show resolved Hide resolved
@jwhitlock jwhitlock added this pull request to the merge queue Sep 10, 2024
jwhitlock added a commit that referenced this pull request Sep 10, 2024
Merged via the queue into main with commit 10eb31e Sep 10, 2024
29 checks passed
@jwhitlock jwhitlock deleted the refactor-relay-sms-exception-mpp3722 branch September 10, 2024 17:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants