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

LJ-386 Fix privacy request receipt notifications #5777

Merged
merged 6 commits into from
Feb 19, 2025
Merged

LJ-386 Fix privacy request receipt notifications #5777

merged 6 commits into from
Feb 19, 2025

Conversation

erosselli
Copy link
Contributor

@erosselli erosselli commented Feb 18, 2025

Closes LJ-386

Description Of Changes

Fixed cryptic error when processing a DSR if send_request_receipt_notification was set to true. The cause of the error was using Set in the type of RequestReceiptBodyParams , because Set is not JSON serializable.

Code Changes

  • src/fides/api/schemas/messaging/messaging.py :
    • Change RequestReceiptBodyParams to use List instead of Set. This is what fixes the issue
    • Added a validator in the FidesopsMessage class to check the provided params match the action_type
    • Updated RequestReviewDenyBodyParams so it doesn't allow extra params. That way other types don't get mistakenly assigned to this type
  • src/fides/api/service/messaging/message_dispatch_service.py -> drive-by change, changed dispatch_message to be called with kwargs cause we were putting property_id in the wrong place

Steps to Confirm

  1. In your fides.toml file, set send_request_receipt_notification = true under [notifications]
  2. Spin up fides, the admin UI and the privacy center
  3. Set up a Messaging provider (e.g mailgun) through the API:
  4. Submit a Privacy Request
  5. You should receive an email that says "Your privacy request has been received. We will get back to you shortly." and no errors should be logged

Pre-Merge Checklist

  • Issue requirements met
  • All CI pipelines succeeded
  • CHANGELOG.md updated
    • Add a db-migration This indicates that a change includes a database migration label to the entry if your change includes a DB migration
    • Add a high-risk This issue suggests changes that have a high-probability of breaking existing code label to the entry if your change includes a high-risk change (i.e. potential for performance impact or unexpected regression) that should be flagged
  • Followup issues:
    • Followup issues created (include link)
    • No followup issues
  • Database migrations:
    • Ensure that your downrev is up to date with the latest revision on main
    • Ensure that your downgrade() migration is correct and works
      • If a downgrade migration is not possible for this change, please call this out in the PR description!
    • No migrations
  • Documentation:
    • Documentation complete, PR opened in fidesdocs
    • Documentation issue created in fidesdocs
    • If there are any new client scopes created as part of the pull request, remember to update public-facing documentation that references our scope registry
    • No documentation updates required

Copy link

vercel bot commented Feb 18, 2025

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

1 Skipped Deployment
Name Status Preview Comments Updated (UTC)
fides-plus-nightly ⬜️ Ignored (Inspect) Visit Preview Feb 19, 2025 4:25pm

@erosselli erosselli requested a review from galvana February 18, 2025 21:38
@galvana
Copy link
Contributor

galvana commented Feb 19, 2025

Looks good 👍
image

Copy link
Contributor

@galvana galvana left a comment

Choose a reason for hiding this comment

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

Thanks for the quick turnaround! I just made one small commit to fix the change log so we could run the tests. I made a recommendation so we'd be able to catch other instances where we're calling the dispatch_message with incorrect params. Don't let that hold this up though.

Comment on lines +68 to +73
db=db,
action_type=schema.action_type,
to_identity=Identity.model_validate(to_identity),
service_type=service_type,
message_body_params=schema.body_params,
property_id=property_id,
Copy link
Contributor

Choose a reason for hiding this comment

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

While we're here, let's add an * to dispatch_message so the optional arguments are required to be passed in as keyword args

def dispatch_message(
    db: Session,
    action_type: MessagingActionType,
    *,
    to_identity: Optional[Identity],
    service_type: Optional[str],
    message_body_params: Optional[
        Union[
            AccessRequestCompleteBodyParams,
            ConsentEmailFulfillmentBodyParams,
            SubjectIdentityVerificationBodyParams,
            RequestReceiptBodyParams,
            RequestReviewDenyBodyParams,
            ErasureRequestBodyParams,
            UserInviteBodyParams,
            ErrorNotificationBodyParams,
        ]
    ] = None,
    subject_override: Optional[str] = None,
    property_id: Optional[str] = None,
) -> None:

Comment on lines +220 to +223
if valid_body_params and not isinstance(self.body_params, valid_body_params):
raise ValueError(
f"Invalid body params for action type {self.action_type}. Expected {valid_body_params.__name__}, got {type(self.body_params).__name__}"
)
Copy link
Contributor

Choose a reason for hiding this comment

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

😎

Copy link

codecov bot commented Feb 19, 2025

Codecov Report

Attention: Patch coverage is 83.33333% with 2 lines in your changes missing coverage. Please review.

Project coverage is 86.81%. Comparing base (94df480) to head (d1035f9).

Files with missing lines Patch % Lines
src/fides/api/schemas/messaging/messaging.py 80.00% 1 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #5777      +/-   ##
==========================================
+ Coverage   84.57%   86.81%   +2.24%     
==========================================
  Files         394      394              
  Lines       24402    24412      +10     
  Branches     2637     2638       +1     
==========================================
+ Hits        20638    21194     +556     
+ Misses       3195     2649     -546     
  Partials      569      569              

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

@erosselli erosselli merged commit 88e6f14 into main Feb 19, 2025
33 of 35 checks passed
@erosselli erosselli deleted the LJ-386 branch February 19, 2025 17:11
Copy link

cypress bot commented Feb 19, 2025

fides    Run #12529

Run Properties:  status check passed Passed #12529  •  git commit 88e6f14e08: LJ-386 Fix privacy request receipt notifications (#5777)
Project fides
Branch Review main
Run status status check passed Passed #12529
Run duration 00m 50s
Commit git commit 88e6f14e08: LJ-386 Fix privacy request receipt notifications (#5777)
Committer erosselli
View all properties for this run ↗︎

Test results
Tests that failed  Failures 0
Tests that were flaky  Flaky 0
Tests that did not run due to a developer annotating a test with .skip  Pending 0
Tests that did not run due to a failure in a mocha hook  Skipped 0
Tests that passed  Passing 5
⚠️ You've recorded test results over your free plan limit.
Upgrade your plan to view test results.
View all changes introduced in this branch ↗︎

erosselli added a commit that referenced this pull request Feb 19, 2025
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.

2 participants