fides icon indicating copy to clipboard operation
fides copied to clipboard

Denote default vs user taxonomy fields

Open allisonking opened this issue 3 years ago • 5 comments

Is your feature request related to a specific problem?

We need a way to tell if a given taxonomy field is one of the fideslang defaults or if it was user generated.

Describe the solution you'd like

Perhaps a field on each taxonomy field that indicates whether or not it was added by the user

Describe alternatives you've considered, if any

A description of any alternative solutions or features you've considered.

Additional context

Add any other context or screenshots about the feature request here.

allisonking avatar Jul 06 '22 15:07 allisonking

It is possible to check the default taxonomy via the python object.

mfbrown avatar Aug 03 '22 17:08 mfbrown

I think the outcome we want is when querying a taxonomy field i.e. /api/v1/data_category, to get the resource back with a field is_default = true | false. There seem to be a few ways to achieve this, and I'm not sure which way is best.

  1. Inspect the DEFAULT_TAXONOMY object to determine which fields are in the default and which are not. This seems easy, but I'm not sure where to do this. The endpoint is generalized to work with all resources, so we probably don't want to add a check like this there. And if we did, we'd also have to update the return type so our docs are accurate (and so that our typescript types can stay accurate!), as right now the return type comes directly from the sql model.
  2. Add a field to the relevant types in sql_models.py. I'm not quite sure how this file works, and what its relationship with the fideslang models file is. But in theory we could add a field is_default there. This would add a column in the database too. We could default is_default=false, and in DEFAULT_TAXONOMY, make all of those is_default=true. However, that would be a trickier migration, since if users already have a taxonomy in their db, the db migration would just mark all of those as not default.
  3. It seems like ideally we could have some sort of solution that is between these two, something like a derived field that doesn't go in the db, but is available on the sql model object? I'm not sure what that would look like though.

Maybe I'm overthinking it?

allisonking avatar Aug 03 '22 20:08 allisonking

@allisonking I actually think #2 will work just fine!

This is the chain of events that happens when the server starts up:

  1. calls configure_db
  2. calls init_db
  3. runs any pending migrations
  4. calls load_default_taxonomy (this function)
  5. load_default_taxonomy upserts the default_taxonomy

Given what happens in step 5, I think we could update this function to pass true for everything in the default taxonomy.

Does that line of logic make sense? Have I missed anything?

ThomasLaPiana avatar Aug 08 '22 08:08 ThomasLaPiana

Aha! yeah if it's an upsert then I think this should work. Is that a fideslang change, or a change in sql_models.py?

allisonking avatar Aug 10 '22 15:08 allisonking

Okay I think I got it: looks like I'll need to update fideslang so that default taxonomy can have a bool is_default, and then also the sql_models in fidesctl to also have a field is_default.

allisonking avatar Aug 10 '22 15:08 allisonking