fides icon indicating copy to clipboard operation
fides copied to clipboard

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

Open adamsachs opened this issue 1 year ago • 8 comments

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):

  • https://github.com/ethyca/fideslang/pull/10
  • https://github.com/ethyca/fides-services/pull/134 (not strictly required to be merged first)

Corresponding downstream PR:

  • https://github.com/ethyca/fidesplus/pull/1392

Code Changes

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

Still TODO:

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

Steps to Confirm

  • [x] tested full stack in corresponding plus PR: https://github.com/ethyca/fidesplus/pull/1392

Pre-Merge Checklist

adamsachs avatar Apr 22 '24 14:04 adamsachs

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

vercel[bot] avatar Apr 22 '24 14:04 vercel[bot]

Passing run #7629 ↗︎

0 4 0 0 Flakiness 0

Details:

Merge aaea874cd1491c2d96f2b5342a0ee408918a78b6 into 0e27b2189e97b98347de649c33d3...
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 ↗︎

cypress[bot] avatar May 01 '24 13:05 cypress[bot]

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!

adamsachs avatar May 02 '24 13:05 adamsachs

Looking @adamsachs!

pattisdr avatar May 02 '24 14:05 pattisdr

lots of failing DSR 3.0 tests 😬

pattisdr avatar May 02 '24 14:05 pattisdr

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!

adamsachs avatar May 02 '24 14:05 adamsachs

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 :warning:
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           

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

codecov[bot] avatar May 02 '24 19:05 codecov[bot]

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 avatar May 03 '24 20:05 adamsachs

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 avatar May 08 '24 02:05 adamsachs