Skip to content

HA-399: migrate existing Cookies resources to Asset resources of type Cookie#5776

Merged
thingscouldbeworse merged 95 commits intomainfrom
HA-399_cookie-to-asset-migration
Apr 17, 2025
Merged

HA-399: migrate existing Cookies resources to Asset resources of type Cookie#5776
thingscouldbeworse merged 95 commits intomainfrom
HA-399_cookie-to-asset-migration

Conversation

@thingscouldbeworse
Copy link
Copy Markdown
Contributor

@thingscouldbeworse thingscouldbeworse commented Feb 18, 2025

Closes #HA-399

Description Of Changes

migrate cookies to asset

Code Changes

  • data migration to turn every entry in the cookies table into an entry in asset with asset_type == 'Cookie'
    • pull the privacy declaration attached to each cookie if it exists and combine the data_use value there into the array data_uses on asset
  • rip out where we previously referenced a cookies property on System and PrivacyDeclaration and prevent creating cookies when upserting these resources
  • retain a privacy notice's ability to have a cookies property which collects assets of type Cookie with a permissive matching data use

Steps to Confirm

  1. list any manual steps for reviewers to confirm the changes

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

@vercel
Copy link
Copy Markdown
Contributor

vercel Bot commented Feb 18, 2025

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

Name Status Preview Comments Updated (UTC)
fides-privacy-center ✅ Ready (Inspect) Visit Preview 💬 Add feedback Apr 17, 2025 2:01am
1 Skipped Deployment
Name Status Preview Comments Updated (UTC)
fides-plus-nightly ⬜️ Ignored (Inspect) Visit Preview Apr 17, 2025 2:01am

Copy link
Copy Markdown
Contributor

@adamsachs adamsachs left a comment

Choose a reason for hiding this comment

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

@thingscouldbeworse looks like you're on the right track here, but there's some nuance/detail that needs to be worked through on the cookies property method 👍

Comment thread src/fides/api/models/privacy_notice.py Outdated
Copy link
Copy Markdown
Contributor

@adamsachs adamsachs left a comment

Choose a reason for hiding this comment

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

this is looking solid @thingscouldbeworse, but two things i think we'll need to address further:

  1. we need to be careful about our query patterns in the data migration. as it stands now, i'm pretty sure on both upgrade and downgrade we're going to be executing n queries for n cookie records on Fides. in a worst case scenario, there could be thousands of cookie records on Fides - it's not likely, but there's at least one GVL vendor who declares thousands of cookies (yuck). in any case, it shouldn't be hard for us to gather the data we need "up front" (either via a JOIN in the query, or via a query up front to pull all the privacy declaration data into memory) rather than execute n queries, so i'd encourage us to do that
  2. it'd be good to verify how this interacts with the fideslang changes you've got queued up, as mentioned on that PR 👍

Comment thread CHANGELOG.md Outdated
Comment thread src/fides/api/db/system.py Outdated
Copy link
Copy Markdown
Contributor

@adamsachs adamsachs left a comment

Choose a reason for hiding this comment

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

@thingscouldbeworse nice work on the migration updates, that's looking solid now (just wanna confirm you've been able to manually test that since we don't have any automated test coverage [not that we need it] 👍 )

then just a couple of other small cleanup items to work through that i've commented on. i'd like to find some time tomorrow to play around a bit with the API behavior myself if an API client specifies cookies, just to see what happens - but that shouldn't be a blocker.

oh, and looks like you need to bump the migration revision head due to other PRs with migrations!

Comment thread requirements.txt Outdated
Comment thread src/fides/api/db/system.py Outdated
Comment thread src/fides/api/models/privacy_notice.py Outdated
Copy link
Copy Markdown
Contributor

@adamsachs adamsachs left a comment

Choose a reason for hiding this comment

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

OK, i think this is generally looking good! will give a tentative approval since i'm going OOO and don't want to hold this up, though there's at least a couple of things we need to adjust:

  • @jpople i think we accidentally removed the cookies column from the datamap report view, we want to keep that there! can you ensure we add that back in sensibly? probably a simple update but i want to let you do that
  • updating the fideslang dep 👍

more substantively: i ran through a migration test of existing cookies just now and the resulting asset table looked good from a spot check, but i would also encourage you @thingscouldbeworse and any ohters to run through a few manual tests with migrating locally - it's the aspect of this body of work that is least reversible and hardest to test (repeatedly) on deployed environment, so it carries the most inherent risk.

the other area is the still-unexplained CI adjustments that were needed. i don't think that's a blocker, but if you've got time to dig on it more, i'd do so, and i'd also just keep our eye out for any otherwise unexplained differences in behavior in main that may arise after we do merge this in...

Comment thread tests/ctl/api/test_seed.py Outdated
import os
from textwrap import dedent
from typing import Generator
from typing import Generator, List
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

nit: feels like a stray addition!

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

removed in f66d5e8

Comment on lines +21 to +27
async def test_upsert_system_malformed_privacy_declaration(
test_config: FidesConfig, system: System, async_session: AsyncSession
) -> None:
with pytest.raises(AttributeError, match="has no attribute 'model_dump'"):
result = await upsert_system(resources=[system], db=async_session)


Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

nit: again this also just feels like a strange addition to have in this PR but i suppose that's OK :)

Comment on lines -454 to -468
columnHelper.accessor((row) => row.cookies, {
id: COLUMN_IDS.COOKIES,
cell: (props) => (
<GroupCountBadgeCell
ignoreZero
suffix="cookies"
value={props.getValue()}
{...props}
/>
),
meta: {
showHeaderMenu: !isRenaming,
width: "auto",
},
}),
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

we shouldn't be removing this @jpople !

@cypress
Copy link
Copy Markdown

cypress Bot commented Apr 17, 2025

fides    Run #12828

Run Properties:  status check passed Passed #12828  •  git commit f64e628f15: HA-399: migrate existing `Cookies` resources to `Asset` resources of type `Cooki...
Project fides
Branch Review main
Run status status check passed Passed #12828
Run duration 00m 51s
Commit git commit f64e628f15: HA-399: migrate existing `Cookies` resources to `Asset` resources of type `Cooki...
Committer Kirk Hardy
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
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

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants