Skip to content
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

add System.vendor_deleted_date db model field; switch DB engines to use custom JSON serialization to handle non-standard data types #4818

Merged
merged 27 commits into from
May 8, 2024

Conversation

adamsachs
Copy link
Contributor

@adamsachs adamsachs commented Apr 22, 2024

Closes PROD-1979

Description Of Changes

Adds in DB model support for a new vendor_deleted_date field on the System model, added in corresponding fideslang model as a potential means of supporting the GVL vendor deleted date field.

As a side effect of this change, a new date field is now needs to be stored in a JSONB field (in the SystemHistory table), we needed to ensure that those fields were being properly encoded (serialized) as JSON to store in the DB. Instead of special-casing this particular field, we decided to update our SQLAlchemy DB engines more broadly to use json (de)serializer functions that leverage our CustomJSONEncoder that handles datetimes and a few other data types that cannot be serialized to JSON via json.dumps().

Corresponding upstream PRs (should be merged first):

Corresponding downstream PR:

Code Changes

  • update DB model
  • add column with DB migration
  • update common DB engines to use CustomJSONEncoder for JSON (de)serialization
  • update (remove) previous manual uses of CustomJSONEncoder for DB fields to leverage the now generic/automatic handling via the DB engine

Still TODO:

  • populate the property on non-bulk compass vendor add?

Steps to Confirm

Pre-Merge Checklist

Copy link

vercel bot commented Apr 22, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

1 Ignored Deployment
Name Status Preview Comments Updated (UTC)
fides-plus-nightly ⬜️ Ignored (Inspect) Visit Preview May 8, 2024 2:17am

@adamsachs adamsachs force-pushed the asachs/PROD-1979-fides-updates branch from fb0d8b5 to 710063a Compare May 1, 2024 13:00
Copy link

cypress bot commented May 1, 2024

Passing run #7629 ↗︎

0 4 0 0 Flakiness 0

Details:

Merge aaea874 into 0e27b21...
Project: fides Commit: 57c7d641c1 ℹ️
Status: Passed Duration: 00:35 💡
Started: May 8, 2024 2:29 AM Ended: May 8, 2024 2:29 AM

Review all test suite changes for PR #4818 ↗︎

@adamsachs adamsachs force-pushed the asachs/PROD-1979-fides-updates branch from 091c69d to ac6474e Compare May 1, 2024 19:16
@adamsachs
Copy link
Contributor Author

ok @pattisdr i think the update to use the custom encoder at the DB engine level is looking good, per our discussion yesterday! (tests seem to be passing).

would like to get your eyes/thoughts on this before moving on further though!

@pattisdr
Copy link
Contributor

pattisdr commented May 2, 2024

Looking @adamsachs!

@pattisdr
Copy link
Contributor

pattisdr commented May 2, 2024

lots of failing DSR 3.0 tests 😬

@adamsachs
Copy link
Contributor Author

lots of failing DSR 3.0 tests 😬

whoops, the tests i ran locally were far too narrow :( i'll take a closer look, sorry for asking prematurely!

Copy link

codecov bot commented May 2, 2024

Codecov Report

Attention: Patch coverage is 98.46154% with 1 lines in your changes are missing coverage. Please review.

Project coverage is 86.79%. Comparing base (1e180ec) to head (eeda81e).

Files Patch % Lines
src/fides/api/task/execute_request_tasks.py 50.00% 1 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             main    #4818   +/-   ##
=======================================
  Coverage   86.78%   86.79%           
=======================================
  Files         346      347    +1     
  Lines       20919    20932   +13     
  Branches     2734     2734           
=======================================
+ Hits        18154    18167   +13     
  Misses       2289     2289           
  Partials      476      476           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Contributor

@pattisdr pattisdr left a comment

Choose a reason for hiding this comment

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

good work @adamsachs 👍 thanks for going the extra mile and getting this custom json serialization and deserialization working more broadly. I'd add this more recent change to the PR description too. I also forgot we were overriding JSON de/serialization in our JSONTypeOverride. nice tracking this down.

requirements.txt Outdated Show resolved Hide resolved
src/fides/api/db/base_class.py Show resolved Hide resolved
src/fides/api/db/session.py Show resolved Hide resolved
src/fides/api/models/privacy_request.py Outdated Show resolved Hide resolved
src/fides/api/models/privacy_request.py Outdated Show resolved Hide resolved
@adamsachs adamsachs changed the title add System.vendor_deleted_date db model field add System.vendor_deleted_date db model field; switch DB engines to use custom JSON serialization to handle non-standard data types May 3, 2024
Copy link
Contributor Author

@adamsachs adamsachs left a comment

Choose a reason for hiding this comment

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

some self-review on my minor FE updates that i'm very unsure about!

Copy link
Contributor

@NevilleS NevilleS left a comment

Choose a reason for hiding this comment

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

The Admin UI types/code changes are pretty solid. I didn't UAT the UI though so you should just grab a quick screenshot and get some eyes from @Kelsey-Ethyca or otherwise to see, since that System form is already pretty monstrous

name="vendor_deleted_date"
id="vendor_deleted_date"
// disable this field for editing:
// deleted date is populated by the GVL and should not be editable by users
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
// deleted date is populated by the GVL and should not be editable by users
// deleted date is populated by Compass and should not be editable by users

super nitpicky but this isn't GVL specific

Copy link
Contributor Author

Choose a reason for hiding this comment

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

hmm, but isn't it GVL specific? that date is coming from the GVL, through compass...

i don't mind making the change here if you think it's more appropriate but my word choice here was somewhat deliberate!

clients/admin-ui/src/types/api/README.md Show resolved Hide resolved
/**
* The deleted date of the vendor that's associated with this system.
*/
vendor_deleted_date?: string;
Copy link
Contributor

Choose a reason for hiding this comment

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

side q: the vendor_deleted_date will always be in the response, right? It'll just be null by default?

(this aspect of the autogenerated types bugs me)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ah yeah that's correct. idk the best way to handle that in typescript, let me know if this is something you think is necessary to adjust

clients/turbo.json Show resolved Hide resolved
@adamsachs
Copy link
Contributor Author

The Admin UI types/code changes are pretty solid. I didn't UAT the UI though so you should just grab a quick screenshot and get some eyes from @Kelsey-Ethyca or otherwise to see, since that System form is already pretty monstrous

for UAT purposes, here are some screenshots of the new field on my local:

  • when creating a system, field is populated from compass:
image
  • when creating a system, field is not populated from compass (vendor doesn't have a deleted_date):
image
  • editing a saved system with the field populated (field is not editable):
image
  • editing a saved system with the field not populated (field is still not editable):
image

@adamsachs adamsachs marked this pull request as ready for review May 6, 2024 18:59
@adamsachs adamsachs requested a review from a team as a code owner May 6, 2024 18:59
@adamsachs
Copy link
Contributor Author

merging, discussed with @Kelsey-Ethyca that she will UAT once it's on main and this is a relatively low-risk update in any case 👍

@adamsachs adamsachs merged commit ea5351a into main May 8, 2024
46 checks passed
@adamsachs adamsachs deleted the asachs/PROD-1979-fides-updates branch May 8, 2024 02:42
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