plaid/plaid-python

get_institution_by_id fails for targets with health incidents without an end date

RobertGraves opened this issue · 1 comments

issue observed on:
plaid-python==10.0.0

utilizing the following code to retrieve an institution by id:

request = InstitutionsGetByIdRequest(
                    institution_id=institution_id,
                    country_codes=[CountryCode('US'),CountryCode('CA')],
                    options=InstitutionsGetByIdRequestOptions(include_status=True)
                )
response = client.institutions_get_by_id(request)

will generate the error

plaid.exceptions.ApiTypeError: Invalid type for variable 'end_date'. Required value type is datetime and passed type was NoneType at ['received_data']['institution']['status']['health_incidents'][0]['end_date']

when the requested institution has an ongoing health incident with no end date listed

these are the kwargs internally at the time of the error:

{
   "status":{
      "auth":{
         "breakdown":{
            "error_institution":"0.186",
            "error_plaid":"0.02",
            "success":"0.793"
         },
         "last_status_change":"2022-10-10T09:50:18Z",
         "status":"DEGRADED"
      },
      "health_incidents":[
         {
            "end_date":"None",
            "incident_updates":"[{'description': 'To maintain system stability, Fidelity currently limits '\n                'access during high-volume windows. As a result, please expect '\n                'unavailability between 9-10:30am and 3-4:30pm ET. We '\n                'recommend end users link Fidelity accounts between 5pm - 9am '\n                'ET.',\n 'status': 'SCHEDULED',\n 'updated_date': datetime.datetime(2022, 2, 11, 23, 24, 59, tzinfo=tzutc())}]",
            "start_date":"'2020-12-10T06:00:00Z'",
            "title":"'Fidelity connectivity restricted during daily windows'"
         }
      ],
      "identity":{
         "breakdown":{
            "error_institution":"0.984",
            "error_plaid":"0.016",
            "success":"0"
         },
         "last_status_change":"2022-10-09T15:25:18Z",
         "status":"DOWN"
      },
      "investments":{
         "breakdown":{
            "error_institution":"0.215",
            "error_plaid":"0.014",
            "success":"0.771"
         },
         "last_status_change":"2022-10-09T15:00:18Z",
         "status":"DEGRADED"
      },
      "investments_updates":{
         "breakdown":{
            "error_institution":"0.003",
            "error_plaid":"0.018",
            "refresh_interval":"'NORMAL'",
            "success":"0.979"
         },
         "last_status_change":"2022-10-11T22:10:18Z",
         "status":"DEGRADED"
      },
      "item_logins":{
         "breakdown":{
            "error_institution":"0.281",
            "error_plaid":"0.019",
            "success":"0.7"
         },
         "last_status_change":"2022-08-29T19:10:18Z",
         "status":"DEGRADED"
      },
      "transactions_updates":{
         "breakdown":{
            "error_institution":"0.077",
            "error_plaid":"0",
            "refresh_interval":"'STOPPED'",
            "success":"0.919"
         },
         "last_status_change":"2022-10-11T11:00:18Z",
         "status":"DOWN"
      }
   }
}

A currently observable institution that has this error is ins_12 which is Fidelity - but any institution with ongoing health incidents with an end_date of None will generate it

This is an issue that should effect any plaid packages that are being generated with a validation of end_date being a datetime field

Suspect validation for this error:
https://github.com/plaid/plaid-python/blob/master/plaid/model/health_incident.py#L88

Hi @RobertGraves, thanks for reporting! This is a known issue that will be fixed in the next release of the client libraries. Slightly more context here: plaid/plaid-openapi#106.