TwilioRestException
There were three errors this morning, which i'm pretty sure was triggered by someone pushing the "test phone" button on production gracedb. The phone number in the traceback below is redacted for privacy.
Internal Server Error: /alerts/contact/1050/request-code/
TwilioRestException at /alerts/contact/1050/request-code/
HTTP 400 error: Unable to create record: Permission to send an SMS has not been enabled for the region indicated by the 'To' number: +81XXXXXXXXXX.
Traceback (most recent call last):
File "/usr/local/lib/python3.7/dist-packages/django/core/handlers/exception.py", line 47, in inner
response = get_response(request)
File "/usr/local/lib/python3.7/dist-packages/django/core/handlers/base.py", line 181, in _get_response
response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "/usr/local/lib/python3.7/dist-packages/django/views/generic/base.py", line 70, in view
return self.dispatch(request, *args, **kwargs)
File "/usr/local/lib/python3.7/dist-packages/django/utils/decorators.py", line 43, in _wrapper
return bound_method(*args, **kwargs)
File "/usr/local/lib/python3.7/dist-packages/django/contrib/auth/decorators.py", line 21, in _wrapped_view
return view_func(request, *args, **kwargs)
File "/usr/local/lib/python3.7/dist-packages/django/views/generic/base.py", line 98, in dispatch
return handler(request, *args, **kwargs)
File "/app/gracedb_project/gracedb/alerts/views.py", line 357, in get
self.object.send_verification_code()
File "/app/gracedb_project/gracedb/alerts/models.py", line 133, in send_verification_code
body=msg)
File "/usr/local/lib/python3.7/dist-packages/twilio/rest/api/v2010/account/message/__init__.py", line 92, in create
data=data,
File "/usr/local/lib/python3.7/dist-packages/twilio/base/version.py", line 209, in create
raise self.exception(method, uri, response, 'Unable to create record')
Exception Type: TwilioRestException at /alerts/contact/1050/request-code/
Exception Value: HTTP 400 error: Unable to create record: Permission to send an SMS has not been enabled for the region indicated by the 'To' number: +81XXXXXXXXXX.
Request information:
USER: hisaaki.shinkai@shibbi.pki.itc.u-tokyo.ac.jp
Based on the username and the country code, maybe something's up with Japanese SMS? Or non-US numbers? This seems like something that needs to be looked up in Twilio and not our implementation.
btw if the USER:
indicator were missing for any reason, you can look up a user's contact info by querying the database in the django shell (python3 manage.py shell
):
In [1]: from alerts.models import Notification, Contact
In [2]: Contact.objects.filter(phone='+81XXXXXXXXXX')
Out[2]: <QuerySet [<Contact: hisaaki.shinkai@shibbi.pki.itc.u-tokyo.ac.jp: Phone and text>]>
Or maybe all the users who have japanese phone numbers:
In [5]: Contact.objects.filter(phone__contains='+81')
Out[5]: <QuerySet [<Contact: hisaaki.shinkai@shibbi.pki.itc.u-tokyo.ac.jp: Phone and text>, <Contact: koh.ueno@ligo.org: test>, <Contact: minori.shikauchi@ligo.org: cellphone>, <Contact: leo.tsukada@ligo.org: phone>, <Contact: leo.tsukada@ligo.org: SMS>]>