-
Notifications
You must be signed in to change notification settings - Fork 1
Enforce uniqueness explicitly #182
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -150,14 +150,19 @@ def log_sample_request(self, request_id: str, device_id: str): | |
| and passed_account_details_check | ||
| ) | ||
|
|
||
| return DeviceIntegritySample.objects.create( | ||
| sample, created = DeviceIntegritySample.objects.get_or_create( | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. How did we decide to keep the old vs new values? It seems like we may want to update to the latest. If we are going to keep the old ones and raise an error on conflict, I think you can leave this as
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Alternatively, we could consider just storing both, since it is a new request and new data from the server side.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Theoretically there won't ever be a "newest" value (only one), because mobile does not make the request twice for the same
If I let the DB error raise I'd have to catch that and return a sensible result to mobile, but the current implementation essentially mimicks that same behaviour with the custom error. I can update if you feel strong about it, but it's not changing any behaviour (just getting rid of a custom error). |
||
| request_id=request_id, | ||
| device_id=device_id, | ||
| is_demo_user=self.is_demo_user, | ||
| google_verdict=raw_verdict, | ||
| passed=check_passed, | ||
| passed_request_check=passed_request_check, | ||
| passed_app_integrity_check=passed_app_integrity_check, | ||
| passed_device_integrity_check=passed_device_integrity_check, | ||
| passed_account_details_check=passed_account_details_check, | ||
| defaults={ | ||
| "device_id": device_id, | ||
| "is_demo_user": self.is_demo_user, | ||
| "google_verdict": raw_verdict, | ||
| "passed": check_passed, | ||
| "passed_request_check": passed_request_check, | ||
| "passed_app_integrity_check": passed_app_integrity_check, | ||
| "passed_device_integrity_check": passed_device_integrity_check, | ||
| "passed_account_details_check": passed_account_details_check, | ||
| }, | ||
| ) | ||
| if not created: | ||
| raise DuplicateSampleRequestError("Duplicate sample request") | ||
| return sample | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So we can track if there's something funky going on...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: I don't think this is strictly necessary (but fine to do). I don't know that getting a duplicate request is something we need to be concerned about, and I want to be in the habit of keeping sentry full of only actionable errors rather than ones we say "that is fine" about as much as we can.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The only reason I added the sentry logging was so we can know if there's spamming or so going on (i.e. endpoint is hit with the same
request_idmultiple times) so we can let mobile know to look into it.