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

Improved privacy request error handling #5500

Merged
merged 18 commits into from
Nov 20, 2024

Conversation

galvana
Copy link
Contributor

@galvana galvana commented Nov 15, 2024

Closes LA-102 and LA-68

Description Of Changes

This PR contains miscellaneous improvements to the privacy request flow.

Code Changes

Main change

  • Fixed issue where database sessions were no longer available after long-running access, erasure, or consent requests

Bug fixes

  • Fixed bug where datasets from disabled integrations were still used in the traversal
  • Fixed bug where privacy request did not transition from approved to in progress
  • Fixed bug where execution log timestamps were incorrect

Misc improvements

  • Updates the privacy request detail page to poll for the latest results as the request is processing
  • Adds a new Dataset traversal timeline event before the actual request starts
  • Removed the extra click between the activity timeline to the event logs
  • Adds the privacy request ID to all privacy request logs

Steps to Confirm

  1. Set the following values in fides.toml
[execution]
use_dsr_3_0 = true

[celery]
task_always_eager = false
  1. Start the test environment with nox -s dev -- postgres, if this fails you might need to run nox -s build
  2. Connect to the postgres_example database and run this SQL script postgres_sample.txt
  3. Create this dataset
    postgres_dataset.txt
  4. Create a new system with a Postgres integration to the postgres_example database. After saving attach the dataset from the previous step
host: host.docker.internal
port: 6432
username: postgres
password: postgres
database: postgres_example
  1. Submit a privacy request via the Privacy Center for jane@example.com
  2. Go the privacy request detail page for this request and approve it. You should see the page auto-update as the request processes
  3. Go back to the integration and disable it, then submit another request. The Postgres dataset should not appear in the activity timeline

Pre-Merge Checklist

  • Issue requirements met
  • All CI pipelines succeeded
  • CHANGELOG.md updated
  • 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 Nov 15, 2024

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 Nov 20, 2024 5:33pm

Copy link

cypress bot commented Nov 15, 2024

fides    Run #11114

Run Properties:  status check passed Passed #11114  •  git commit 514567e1b2 ℹ️: Merge 9baf5e4931813ad690114a9e4fc8501efd380d9e into 0a7a2b2feb03717bbc5297eb0bc9...
Project fides
Branch Review refs/pull/5500/merge
Run status status check passed Passed #11114
Run duration 00m 39s
Commit git commit 514567e1b2 ℹ️: Merge 9baf5e4931813ad690114a9e4fc8501efd380d9e into 0a7a2b2feb03717bbc5297eb0bc9...
Committer Adrian Galvan
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 4
⚠️ You've recorded test results over your free plan limit.
Upgrade your plan to view test results.
View all changes introduced in this branch ↗︎

Copy link

codecov bot commented Nov 15, 2024

Codecov Report

Attention: Patch coverage is 97.56098% with 1 line in your changes missing coverage. Please review.

Project coverage is 85.19%. Comparing base (1c8b2d7) to head (2a1c2cc).

Files with missing lines Patch % Lines
.../service/privacy_request/request_runner_service.py 88.88% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #5500      +/-   ##
==========================================
+ Coverage   85.18%   85.19%   +0.01%     
==========================================
  Files         387      387              
  Lines       24265    24285      +20     
  Branches     2646     2649       +3     
==========================================
+ Hits        20669    20689      +20     
  Misses       3042     3042              
  Partials      554      554              

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

Consistent privacy request logging
New traversal entry in activity timeline
Copy link
Contributor

@eastandwestwind eastandwestwind left a comment

Choose a reason for hiding this comment

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

Nice work so far @galvana ! I like how you've fortified our logging by adding additional args into @log_context decorator.

Can you explain more about how you envision future devs should use this decorator in combination with manual log statements?


type ActivityTimelineProps = {
subjectRequest: PrivacyRequestEntity;
setEventDetails: (d: EventData) => void;
};

const hasUnresolvedError = (entries: ExecutionLog[]) => {
Copy link
Contributor

Choose a reason for hiding this comment

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

I know this method existed before- but mind adding a short docstring explaining what this does? Specifically- what an "unresolved" error means vs just an error?

src/fides/api/models/privacy_request.py Show resolved Hide resolved
src/fides/api/task/create_request_tasks.py Show resolved Hide resolved
src/fides/api/task/execute_request_tasks.py Show resolved Hide resolved
src/fides/api/util/logger_context_utils.py Show resolved Hide resolved
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I broke out the TimelineEntry and LogDrawer into separate components. I also removed the EventDetails component since it added unnecessary click before opening the LogDrawer


def upgrade():
op.alter_column(
"executionlog", "created_at", server_default=text("clock_timestamp()")
Copy link
Contributor Author

Choose a reason for hiding this comment

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

The previous server_default for the created_at and updated_at columns of ExecutionLog were set to now(). This meant that when the execution log entry was written to the database it would use the timestamp from when the database session was opened instead of when the ExecutionLog entry was created. Changing this to clock_timestamp() makes it so we don't used the cached timestamp and use the actual event creation time. This value is still calculated on the database so there's no issues with application time inconsistencies in the case of multiple webservers or workers.

Copy link
Contributor

Choose a reason for hiding this comment

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

This makes sense!

src/fides/api/graph/traversal.py Show resolved Hide resolved
src/fides/api/models/privacy_request.py Show resolved Hide resolved
src/fides/api/task/execute_request_tasks.py Show resolved Hide resolved
src/fides/api/util/logger_context_utils.py Show resolved Hide resolved
@galvana galvana marked this pull request as ready for review November 19, 2024 01:33
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I simplified this so it's easier to understand

@galvana galvana added the run unsafe ci checks Runs fides-related CI checks that require sensitive credentials label Nov 19, 2024
Copy link
Contributor

@eastandwestwind eastandwestwind left a comment

Choose a reason for hiding this comment

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

Nice work @galvana !

@galvana galvana merged commit 97edac0 into main Nov 20, 2024
20 checks passed
@galvana galvana deleted the LA-102-improve-privacy-request-error-handling branch November 20, 2024 17:34
Copy link

cypress bot commented Nov 20, 2024

fides    Run #11115

Run Properties:  status check passed Passed #11115  •  git commit 97edac0ea8: Improved privacy request error handling (#5500)
Project fides
Branch Review main
Run status status check passed Passed #11115
Run duration 00m 39s
Commit git commit 97edac0ea8: Improved privacy request error handling (#5500)
Committer Adrian Galvan
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 4
⚠️ You've recorded test results over your free plan limit.
Upgrade your plan to view test results.
View all changes introduced in this branch ↗︎

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
run unsafe ci checks Runs fides-related CI checks that require sensitive credentials
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants