-
Notifications
You must be signed in to change notification settings - Fork 72
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
move privacy declarations to their own table #3098
move privacy declarations to their own table #3098
Conversation
0565173
to
3295b50
Compare
Passing run #1544 ↗︎
Details:
This comment has been generated by cypress-bot as a result of this project's GitHub integration settings. |
f392170
to
d3be6a1
Compare
Codecov ReportPatch coverage:
Additional details and impacted files@@ Coverage Diff @@
## main #3098 +/- ##
==========================================
- Coverage 87.52% 87.47% -0.05%
==========================================
Files 309 309
Lines 17840 17924 +84
Branches 2310 2325 +15
==========================================
+ Hits 15614 15679 +65
- Misses 1802 1820 +18
- Partials 424 425 +1
... and 1 file with indirect coverage changes Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. ☔ View full report in Codecov by Sentry. |
ef2427e
to
47aa334
Compare
This is still a bit rough around the edges, so i'll look to finalize some testing and polish, but in the meantime i wanted to get some preliminary eyes on it since i'm hoping this is how things will look generally, and want to know if there are any red flags. @ThomasLaPiana - i think you're most familiar with |
codecov is complaining about a lot of places that i'm just about positive are covered by tests i've added (mainly in |
Starting a review @adamsachs ... |
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.
there appears to be something bugging out in the frontend when there are two declarations with the same data use
Screen.Recording.2023-04-20.at.12.51.49.PM.mov
the FE was doing some logic to make sure we didn't get duplicate privacy declarations (declarations with the same data use AND the same name). this was because there was never a unique constraint on the BE for privacy declarations back when they were a json blob. since declarations also didn't have IDs, the frontend had to do some other weird stuff to work around that.
I suspect those workarounds combined with something in this change is creating this bug. I can look into it, but curious if you have any immediate thoughts first @adamsachs ?
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.
Didn't spend as much time as I normally would here as it's in draft, but generally agree with the approach. Nice work especially on the upserting privacy declaration logic.
src/fides/api/ctl/migrations/versions/48d9caacebd4_create_privacy_declarations_table.py
Outdated
Show resolved
Hide resolved
ah yes thanks for pointing this out @allisonking! i'd assumed that a given So tagging in @mfbrown and @rsilvery - do we want to allow for more than one 'privacy declaration' pointing to a particular |
@mfbrown didn't this come up with Momentive and we changed it so you could have the same |
That is correct. There is a need to have the same data use more than once on a system and the check for uniqueness is against both the Use + Activity (which is the declaration name in the BE, i believe) |
thanks @adamsachs ! let me know if you want me to take a look again. if you update the BE to have that behavior and the FE still isn't behaving, let me know, since it could definitely be that the FE logic is no longer relevant. regardless, once this PR is in, I'll make a follow up ticket to update some of the FE, since I don't think it'll need to do as many checks as it is doing right now :) one other thing I noticed—I tried to autogenerate some typescript types based off of the openapi spec and noticed the spec for a |
1e7fff7
to
4193756
Compare
marking this as ready for review as i think i've addressed all the major concerns/decisions from the initial review! @allisonking i've pushed a new tag 2.11.1a4 that can be used for some testing if you'd like. i ran through things (though not in |
hi @pattisdr @ThomasLaPiana, a friendly nudge on this for another round of BE review as i'd like to get this merged ASAP since there are a few subsequent pieces of functionality due this sprint that depend on this. i'll be out for most of the earlier part of the day on monday but should be able to circle back to address any feedback monday evening, if either of you are able to take a look earlier in the day. i would really appreciate it! |
thanks @adamsachs don't worry I haven't forgotten! |
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.
works well @adamsachs just a couple of cleanup things, the main refactoring to FK to system id instead of system fides_key looks good, and also the soft references to the data use.
@adamsachs Great work here, lots of places to trip-up but it looks like they all got solved 😄 As for the codecov, I looked through the new API tests and the codecov "missed lines". It is possible that some of those error states (mostly what it says is missing) aren't getting caught, but I'm not majorly concerned here either. I am unsure why the loss in coverage is so large though |
maintain backward compatibility with existing system API by manually handling the privacy declarations defined inline on system create/update requests.
some other cleanup of system routes
do not establish a hard FK link with DataUse records. other minor cleanup.
56c6f9f
to
a578fbe
Compare
❗ Contains migration; check downrev before merge
Closes #3036
Moves the objects stored in the JSON blob (array) column of
System.privacy_declarations
into their own table,privacydeclarations
. All fields previously on theprivacy_declaration
objects are now columns on this new table. Additionally each record in the new table points via FK to their associatedSystem
record (identified by itsfides_key
); we also are able to make a proper FK link to the associatedDataUse
records, which are also identified byfides_key
- previously, this was just a string field on the JSON object.Maintains backward compatibility with existing "system" API by manually handling the privacy declarations defined inline on system create/update requests. There were already special-cased endpoints for
System
objects outside of the genericcrud.py
API due to special handling for system manager permissions - we build out those special-cased endpoints a bit further here. We're able to leverage the existing pydantic models (stored infideslang
) just about as-is - there was only a trivialfideslang
update needed (v1.3.4
) to setorm_mode = True
on thePrivacyDeclaration
model class.Note that at this point, there's no API to interact with
PrivacyDeclaration
records directly. We may want to build that out in the future, but for now, keeping the API interactions through theSystem
will support the existing UI just fine, and it allows us to limit our surface area of these changes a bit.Code Changes
PrivacyDeclaration
table and associated SQLAlchemy modelSystem.privacy_declaration
dataSystem
(which will cascade deletes, i.e.System
is the "parent" object) and toDataUse
, which means that the declaration MUST point to an existingDataUse
System
APIs to create and maintainPrivacyDeclaration
recordsPUT
/update
function to upsertPrivacyDeclaration
records associated with theSystem
, as defined by theirDataUse
POST
/create
function for systems to createPrivacyDeclaration
records associated with theSystem
/upsert
function to perform the update logic above for bulk upserts. note that we did not already have a special-cased/upsert
function forSystem
, i'm not exactly sure on the permissions implicationsprivacy_declarations
off of aSystem
record via the back-populated relationship, so things mostly look the same for other parts of the codebase interacting with these records.Steps to Confirm
Pre-Merge Checklist
CHANGELOG.md
Description Of Changes
As privacy declarations (i.e. the data uses associated with a system) become more central to our application, it will benefit us to have them in their own table, with proper FK links to
System
records andDataUse
s. This will allow us to manage and query them much more easily moving forward.The specific motivation for this change was to allow custom fields to apply to a given
PrivacyDeclaration
record, which wouldn't have been possible if they were defined as embedded JSON.