plaid / plaid-ruby

Ruby bindings for Plaid
https://plaid.com/docs
MIT License
225 stars 143 forks source link

IdentityVerificationUserData is not checking for nil on phone number response #437

Closed aaronbhansen closed 1 year ago

aaronbhansen commented 2 years ago

I create a request for new PlaidApi.identity_verification_create, and with debugging enabled, I can see it makes the request and returns the response. When it is serializing the data back, it throws a validations exception because the return class isn't checking for phone number nil.

I get the validation message: invalid value for "phone_number", must conform to the pattern (?-mix:^\+[1-9]\d{6,14}$).

Looking at the IdentityVerificationUserData vs the IdentityVerificationRequestUser. The Request user checks that phone number is nil to validate, the UserData model doesn't.

Here is the full debug

 [www] [443b6535-b494-433e-bfdb-6e7190630957] Calling API: PlaidApi.identity_verification_create ...
 [www] [443b6535-b494-433e-bfdb-6e7190630957] HTTP request body param ~BEGIN~
 {"is_shareable":false,"template_id":"idvtmp_6JrHfhpsFQZo4x","gave_consent":false,"user":{"client_user_id":"user_1973999_1"},"is_idempotent":true}
 ~END~

 [www] [443b6535-b494-433e-bfdb-6e7190630957] HTTP response body ~BEGIN~
 {
   "client_user_id": "user_1973999_1",
   "completed_at": null,
   "created_at": "2022-08-25T17:48:16Z",
   "documentary_verification": null,
   "id": "idv_2VgVht7rENo8qr",
   "kyc_check": null,
   "previous_attempt_id": null,
   "request_id": "1vtPiFioYGGWEtc",
   "shareable_url": null,
   "status": "active",
   "steps": {
     "accept_tos": "active",
     "documentary_verification": "not_applicable",
     "kyc_check": "waiting_for_prerequisite",
     "risk_check": "waiting_for_prerequisite",
     "selfie_check": "not_applicable",
     "verify_sms": "waiting_for_prerequisite",
     "watchlist_screening": "waiting_for_prerequisite"
   },
   "template": {
     "id": "idvtmp_6JrHfhpsFQZo4x",
     "version": 1
   },
   "user": {
     "address": null,
     "date_of_birth": null,
     "email_address": null,
     "id_number": null,
     "ip_address": null,
     "name": null,
     "phone_number": null
   },
   "watchlist_screening_id": null
 }
 ~END~

 [www] [443b6535-b494-433e-bfdb-6e7190630957] Completed 500 Internal Server Error in 730ms (ActiveRecord: 34.6ms | Allocations: 58937)

 [www] [443b6535-b494-433e-bfdb-6e7190630957]
 ArgumentError - invalid value for "phone_number", must conform to the pattern (?-mix:^\+[1-9]\d{6,14}$).:
   app/integrations/plaid_integration/interface.rb:39:in `request_and_save_identity_verification!'
phoenixy1 commented 2 years ago

@aaronbhansen thank you for reporting this issue! We actually just recently ran into this internally and have a fix in progress. It should go out with the next client library release.