Skip to content

LG-12041: Prevent user from resubmitting a selfie that already failed portrait matching#9976

Merged
amirbey merged 23 commits intomainfrom
amirbey/LG-12041-selfie-fingerprinting
Jan 31, 2024
Merged

LG-12041: Prevent user from resubmitting a selfie that already failed portrait matching#9976
amirbey merged 23 commits intomainfrom
amirbey/LG-12041-selfie-fingerprinting

Conversation

@amirbey
Copy link
Contributor

@amirbey amirbey commented Jan 25, 2024

🎫 Ticket

LG-12041

🛠 Summary of changes

  • add selfie_failed_images to DocumentCaptureSessionResult
  • store selfie image in selfie_failed_images when portrait match fails
  • add failed selfie images to failed_selfie_image_fingerprints when failing in vendor response

📜 Testing Plan

Provide a checklist of steps to confirm the changes.

  • Submit doc auth with invalid selfie
  • Click Try Again
  • Submit doc auth with invalid selfie
  • Verify error preventing resubmission of same selfie

@amirbey amirbey changed the title Amirbey/lg 12041 selfie fingerprinting LG-12041: Prevent user from re-uploading a selfie that already failed portrait matching Jan 25, 2024
@amirbey amirbey force-pushed the amirbey/LG-12041-selfie-fingerprinting branch from 1be1272 to 11aec33 Compare January 26, 2024 00:05
@amirbey amirbey marked this pull request as ready for review January 26, 2024 20:00
@amirbey amirbey self-assigned this Jan 26, 2024
@amirbey amirbey changed the title LG-12041: Prevent user from re-uploading a selfie that already failed portrait matching LG-12041: Prevent user from resubmitting a selfie that already failed portrait matching Jan 29, 2024
Copy link
Contributor

@charleyf charleyf left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Curious if the work around selfie_status_from_response can be moved to a different PR? It seems distinct and the fingerprint work seems like it can stand alone? I may be missing something that ties the two things together?

Comment on lines +482 to +484
front_image_fingerprint: failed_front_fingerprint,
back_image_fingerprint: failed_back_fingerprint,
selfie_image_fingerprint: extra_attributes[:selfie_image_fingerprint],
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems odd to me that we have failed_front_fingerprint and failed_back_fingerprint then extra_attributes[:selfie_image_fingerprint]. I'm not saying that using extra_attributes is wrong, more that I'd expect we're doing the same things with all three images and I'm not sure why the selfie is different?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hey @charleyf 👋🏿 - the doc auth result errors exist across 2 granular parts (front and back image) and the front and failed_(front|back)_fingerprints are defined conditionally based on doc auth response errors that may exist for the front or back images. here we are are always passing the fingerprint to the the document capture session

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah. The reason I was asking is that it felt weird to me that we needed semi-complex conditional logic for the front and back and not the selfie.

The more I think about this, the more I'm pretty sure that the conditional logic here needs to change to reflect how we want to handle selfie_fingerprint errors.

My reasoning:

  • if client_response && !client_response.success? && !client_response.network_error? is checking "Did the client response fail in a way where we should store the image fingerprints as 'failed' ?"
    • This means that when selfie is enabled, we'll always store the selfie fingerprint, regardless if it was the selfie that failed. This is where I'd expect a check on the :selfie_status === :Fail
  • elsif doc_pii_response && !doc_pii_response.success?
    • This says "If the doc_pii_response fails"
    • selfie_image_fingerprint: extra_attributes[:selfie_image_fingerprint], then mark the selfie as failed.
    • I don't think that in this case we do actually want to fail the selfie? The PII is not affected by the selfie?

Copy link
Contributor Author

@amirbey amirbey Jan 30, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@charleyf - here we are always passing the selfie fingerprint but conditionally store the selfie_fingerprint

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Interesting, I missed that. Does it make sense to match failed_front_fingerprint and back_image_fingerprint and do something like this in store_failed_images?

      failed_selfie_fingerprint = nil
      if client_response && client_response.selfie_status == :Fail
          failed_selfie_fingerprint = extra_attributes[:selfie_image_fingerprint]
      end

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, i did think about that 🤔

my reasoning for putting this condition in the DocumentCaptureSession was that if we call store_failed_auth_data in more places in the future it would require us to remember and duplicate this condition/code. however, in regards to the front and back fingerprint values, the business logic for storing front and back images is pretty specific to the errors here and also can happen if doc auth result fails while we have no errors returned from the vendor.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That makes sense, I would still expect the conditionals that determine when we store fingerprints to be in one place: either store_failed_images or DocumentCaptureSession, but I may be misunderstanding a benefit here.

Either of these would make more sense to me in the session 🤷

session_result.add_failed_front_image!(front_image_fingerprint)  if front_image_fingerprint
session_result.add_failed_back_image!(back_image_fingerprint)  if back_image_fingerprint
session_result.add_failed_selfie_image!(selfie_image_fingerprint) if selfie_image_fingerprint
session_result.add_failed_front_image!(front_image_fingerprint)
session_result.add_failed_back_image!(back_image_fingerprint)
session_result.add_failed_selfie_image!(selfie_image_fingerprint)

@amirbey amirbey requested a review from charleyf January 30, 2024 19:35
Copy link
Contributor

@charleyf charleyf left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm running through some test cases now, will likely approve after that.

Rack::Test::UploadedFile.new(path, Mime[:yaml])
end

def self.portrait_match_success_yaml
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 Interesting, I didn't know about this fixtureing file. I think I just saw some test files that can benefit from this.

Comment on lines +482 to +484
front_image_fingerprint: failed_front_fingerprint,
back_image_fingerprint: failed_back_fingerprint,
selfie_image_fingerprint: extra_attributes[:selfie_image_fingerprint],
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That makes sense, I would still expect the conditionals that determine when we store fingerprints to be in one place: either store_failed_images or DocumentCaptureSession, but I may be misunderstanding a benefit here.

Either of these would make more sense to me in the session 🤷

session_result.add_failed_front_image!(front_image_fingerprint)  if front_image_fingerprint
session_result.add_failed_back_image!(back_image_fingerprint)  if back_image_fingerprint
session_result.add_failed_selfie_image!(selfie_image_fingerprint) if selfie_image_fingerprint
session_result.add_failed_front_image!(front_image_fingerprint)
session_result.add_failed_back_image!(back_image_fingerprint)
session_result.add_failed_selfie_image!(selfie_image_fingerprint)

Copy link
Contributor

@charleyf charleyf left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I ran through a few testing scenarios and this seems to work.

Notes:

  • The mock proofer makes it hard to test this in dev, staging is a much better test.
  • There are a bunch of analytics events in analytics_events.rb with front_image_fingerprint and back_image_fingerprint that haven't had selfie_image_fingerprint added.

@amirbey amirbey merged commit 9aea097 into main Jan 31, 2024
@amirbey amirbey deleted the amirbey/LG-12041-selfie-fingerprinting branch January 31, 2024 18:48
Copy link
Contributor

@dawei-nava dawei-nava left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

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.

3 participants