-
Notifications
You must be signed in to change notification settings - Fork 78
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
[Backend] Fix Validation Error where Current Privacy Preferences might be None #3719
Conversation
…n rapid succession could cause a ValidationError. - The CurrentPrivacyPreference table has a FK to the PrivacyPreferenceHistory record that it corresponds to. If another PrivacyPreferenceHistory record is saved for the same notice and user, the CurrentPrivacyPreference record is upserted to point to the latest PrivacyPreferenceHistory record that created it. If a PrivacyPreferenceHistory record for a given notice/user has had more recent preferences saved, there is not CurrentPrivacyPreference relationship, which can return None. The endpoint saving preferences returns all the upserted CurrentPrivacyPreference records. If this has happened too quickly, it was possible that value was None.
@adamsachs hoping you could review this small change - it was the source of the first error we were running into here, creating higher than expected failure rates. |
Passing run #3050 ↗︎Details:
This comment has been generated by cypress-bot as a result of this project's GitHub integration settings. |
Codecov ReportPatch coverage:
Additional details and impacted files@@ Coverage Diff @@
## main #3719 +/- ##
===========================================
+ Coverage 65.24% 87.07% +21.83%
===========================================
Files 310 310
Lines 19033 19019 -14
Branches 2456 2454 -2
===========================================
+ Hits 12418 16561 +4143
+ Misses 6178 2029 -4149
+ Partials 437 429 -8
☔ View full report in Codecov by Sentry. |
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.
nice simple fix! i'm sure it was tougher to track down the timing problem than it was to actually fix it once you found it 😄
manually verified no obvious regressions in the PATCH /api/v1/privacy-preferences
endpoint per your steps.
have you confirmed this fixes the problem you'd seen in load testing? not a prerequisite for merging, just curious if that's something you'd been able to do before merging.
@adamsachs yes! you're able to hit this error locally if you send requests at a high enough rate, and I did verify that this particular error has gone away. Thanks for reviewing this! |
Conflicts - changelog
Failing test not related and ticketed here: #3736 |
Closes https://github.com/ethyca/fidesplus/issues/979
Description Of Changes
Under higher loads, saving Privacy Preferences could return Pydantic Validation Errors because the CurrentPrivacyPreferenceSchema is not supposed to be None.
The root cause is that if a single user saves their preferences in rapid succession, the older PrivacyPreferenceHistory history record will no longer have a relationship with the CurrentPrivacyPreference record because a newer PrivacyPreferenceHistory had superseded it.
Code Changes
Steps to Confirm
Example request:
Pre-Merge Checklist
CHANGELOG.md