google / exposure-notifications-verification-server

Verification component for COVID-19 Exposure Notifications.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

api/issue incomplete IssueCodeResponse

kantmakm opened this issue · comments

TL;DR

When programmatically sending to the api/issue endpoint our scripts have been getting back an errorCode per the api documentation. That stopped with today's batch. We have changed our code to look for 'error' instead and that seems to be working.

Expected behavior
IssueCodeResponse:

{
  "uuid": "string UUID",
  "code": "short verification code",
  "expiresAt": "RFC1123 formatted string timestamp",
  "expiresAtTimestamp": 0,
  "expiresAt": "RFC1123 UTC timestamp",
  "expiresAtTimestamp": 0,
  "longExpiresAt": "RFC1123 UTC timestamp",
  "longExpiresAtTimestamp": 0,
  "error": "descriptive error message",
  "errorCode": "well defined error code from api.go",
}

Observed behavior
IssueCodeResponse

{
  "uuid": "string UUID",
  "code": "short verification code",
  "expiresAt": "RFC1123 formatted string timestamp",
  "expiresAtTimestamp": 0,
  "expiresAt": "RFC1123 UTC timestamp",
  "expiresAtTimestamp": 0,
  "longExpiresAt": "RFC1123 UTC timestamp",
  "longExpiresAtTimestamp": 0,
  "error": "descriptive error message",
}

Python script used to work:

        elif response.status_code == 400:
            response_text = response.json()
            log_line_for_retry('400_error', row)
            logging.warning(f"400 error for CEDRS '{row[CEDRS_ID]}' phone number '{row[PHONE_NUMBER]}' status  '{response.status_code}' error '{response_text['    error']}' errorcode '{response_text['**errorCode**']}'. \U0001F44E ")
            continue

failure log:

Traceback (most recent call last):
  File "sendcodes_v2.py", line 190, in <module>
    logging.warning(f"400 error for CEDRS '{row[CEDRS_ID]}' phone number '{row[PHONE_NUMBER]}' status  '{response.status_code}' error '{response_text['error']}' errorcode '{response_text['errorCode']}'. \U0001F44E ")
KeyError: 'errorCode'

Code change to workaround missing errorCode

        elif response.status_code == 400:
            response_text = response.json()
            log_line_for_retry('400_error', row)
            logging.warning(f"400 error for CEDRS '{row[CEDRS_ID]}' phone number '{row[PHONE_NUMBER]}' status  '{response.status_code}' error '{response_text['    error']}' errorcode '{response_text['**error**']}'. \U0001F44E ")
            continue

@ kantmakm
Are you seeing that errorCode is missing when there is an actual error?

If so - can you share the error message so we can trace this code path?

Yes - errorCode is no longer being returned when an error occurs. These are log entries from passing the same record through to the the api/issue endpoint - the first crashed our process (i know, i know) as it was expecting errorCode back, the second continued after replacing errorCode with error:

WARNING:root:Failedrow - 400_error: ,Confirmed,966031,5555551212,01/12/2021.

WARNING:root:400 error for CEDRS '111111' phone number '5555551212' status '400' error 'failed to send sms: The 'To' phone number: +15555551212, is not currently reachable using the 'From' phone number: 55512 via SMS.' errorcode 'failed to send sms: The 'To' phone number: +15555551212, is not currently reachable using the 'From' phone number: 55512 via SMS.'. 👎