-
Notifications
You must be signed in to change notification settings - Fork 73
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
PROD-2134: Adds validation for taxonomy labels #4982
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎ 1 Ignored Deployment
|
from alembic import op | ||
import sqlalchemy as sa | ||
|
||
from alembic import op |
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.
running the static_checks
command caused this change
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.
Thanks for including this cleanup here 👍
from fides.api.schemas.messaging.messaging import MessagingMethod, MessagingActionType | ||
from fides.api.schemas.messaging.messaging import MessagingActionType, MessagingMethod |
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.
the same happened here
@@ -48,27 +52,40 @@ def get_system(db: Session, fides_key: str) -> System: | |||
return system | |||
|
|||
|
|||
async def validate_data_labels( |
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.
Wasn't sure what the best name for this was so suggestions are appreciated 😄
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.
sounds good to me, a docstring added to this function will add further clarification
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.
I have added the docstring in 61b7cea
Passing run #8330 ↗︎
Details:
Review all test suite changes for PR #4982 ↗︎ |
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #4982 +/- ##
==========================================
- Coverage 86.59% 86.59% -0.01%
==========================================
Files 349 349
Lines 21620 21628 +8
Branches 2867 2869 +2
==========================================
+ Hits 18722 18728 +6
- Misses 2394 2395 +1
- Partials 504 505 +1 ☔ View full report in Codecov by Sentry. |
06e0963
to
ce35806
Compare
81d86af
to
9df6aaf
Compare
Starting review - |
src/fides/api/db/system.py
Outdated
@@ -48,27 +52,47 @@ def get_system(db: Session, fides_key: str) -> System: | |||
return system | |||
|
|||
|
|||
async def validate_data_labels( | |||
db: AsyncSession, sql_model: Base, labels: List[FidesKey] |
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.
technically I'd want to type sql_model
with something more specific than Base
since I'm assuming that resource has an active
property but wasn't sure if this was something I could do 😅 I'm not too familiar with Python type annotations so don't know how complex I can get with the types
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.
most things inherit from Base
so it's technically correct, but I think it might be too broad here, especially since Base isn't guaranteed to have the active
property. For now, since you're calling this in one place, I might annotate with the known resources you're calling with, a data category, a data subject, and a use, like:
sql_model: Union[Type[DataUse], Type[DataSubject], Type[DataCategory]]
The Type
is there because it's not an instance of a DataUse you're passing in, rather it's just a class definition
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.
I have updated this in 61b7cea 😄
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.
Excellent first PR - detailed test coverage and manual testing steps for QA, and a self-review to help the code reviewer focus more in certain areas. Love it.
A couple of very minor things requested, there's a few failing tests still, and then you'll need to add an entry to CHANGELOG.md as well -
from alembic import op | ||
import sqlalchemy as sa | ||
|
||
from alembic import op |
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.
Thanks for including this cleanup here 👍
@@ -48,27 +52,40 @@ def get_system(db: Session, fides_key: str) -> System: | |||
return system | |||
|
|||
|
|||
async def validate_data_labels( |
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.
sounds good to me, a docstring added to this function will add further clarification
src/fides/api/db/system.py
Outdated
@@ -48,27 +52,47 @@ def get_system(db: Session, fides_key: str) -> System: | |||
return system | |||
|
|||
|
|||
async def validate_data_labels( | |||
db: AsyncSession, sql_model: Base, labels: List[FidesKey] |
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.
most things inherit from Base
so it's technically correct, but I think it might be too broad here, especially since Base isn't guaranteed to have the active
property. For now, since you're calling this in one place, I might annotate with the known resources you're calling with, a data category, a data subject, and a use, like:
sql_model: Union[Type[DataUse], Type[DataSubject], Type[DataCategory]]
The Type
is there because it's not an instance of a DataUse you're passing in, rather it's just a class definition
status_code=HTTP_400_BAD_REQUEST, | ||
detail=f"Invalid privacy declaration referencing unknown DataUse {privacy_declaration.data_use}", | ||
) | ||
await validate_data_labels(db, DataUse, [privacy_declaration.data_use]) |
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, putting this in a list so validate_data_labels can be reused 👍
df721d6
to
2026d64
Compare
2026d64
to
f5091b2
Compare
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.
Great @erosselli! Test coverage looks good to me. This can be merged 👍
Passing run #8332 ↗︎
Details:
Review all test suite changes for PR #4982 ↗︎ |
Closes PROD-2134
Description Of Changes
When creating or updating a
System
, we now validate that it referencesDataUses
,DataCategories
, andDataSubjects
that both exist and have theiractive
attribute set toTrue
.Code Changes
validate_privacy_declarations
method to add validation forDataCategories
andDataSubjects
and to update the validation forDataUses
Steps to Confirm
Testing for invalid taxonomy labels
POST api/v1/system
endpoint in the Swagger UI, or alternatively make the request from Postman"user.contact.company_website"
):The same can be done for invalid data uses and data subjects.
Testing for disabled taxonomy labels
POST api/v1/system
endpoint in the Swagger UI, or alternatively make the request from Postman"user.contact.company_website"
for a privacy declaration in the request body, see example JSON below:The same can be done for disabled data uses and data subjects.
Pre-Merge Checklist
CHANGELOG.md
main
downgrade()
migration is correct and works