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

HJ-97 - Update systems endpoint to filter vendor deleted systems #5553

Merged
merged 4 commits into from
Dec 4, 2024

Conversation

andres-torres-marroquin
Copy link
Contributor

@andres-torres-marroquin andres-torres-marroquin commented Dec 2, 2024

Closes #HJ-97

Description Of Changes

Update systems endpoint to filter vendor deleted systems

Code Changes

  • Updates /system list endpoint to filter out vendor deleted systems.

Steps to Confirm

For System resource:

  1. Create a system
  2. Update the vendor_deleted_at field for the newly created system to something in the past (if it is null or in the future it won't be filtered out)
  3. List /system the created system should be filtered out.

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 Dec 2, 2024

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

Name Status Preview Comments Updated (UTC)
fides-plus-nightly ✅ Ready (Inspect) Visit Preview 💬 Add feedback Dec 4, 2024 1:04pm

Copy link

cypress bot commented Dec 2, 2024

fides    Run #11255

Run Properties:  status check passed Passed #11255  •  git commit 6050403523 ℹ️: Merge be246492bc45737615995908d0188e93da6e5569 into 8723d8468f9916b26a5434c4b02b...
Project fides
Branch Review refs/pull/5553/merge
Run status status check passed Passed #11255
Run duration 00m 49s
Commit git commit 6050403523 ℹ️: Merge be246492bc45737615995908d0188e93da6e5569 into 8723d8468f9916b26a5434c4b02b...
Committer Andres Torres
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
View all changes introduced in this branch ↗︎

Copy link
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, this is looking good in some brief manual testing - I'll tentatively approve, but a few notes:

  • i left a comment on the ticket to confirm with product that we're OK filtering these out of the system list endpoint (and system inventory page) while not filtering out of the reporting pages
  • there are some minor points in the code about backward compatibility/stylistic points that'd be nice to address
  • it's probably worth improving the "steps to confirm" in the PR description, since adding a "vendor deleted date" is not a self-explanatory step, since the UI doesn't support manually editing this field (i don't think?). i'd either:
    • provide steps on how to test this integrated with fidesplus - which would consist of creating a system based on a compass vendor who actually has avendor_deleted_date populated. this is the best test, since it more closely mimics the actual use case in the ticket. note that i didn't complete this testing myself.
    • provide a sample API request that you used to set a vendor_deleted_date "manually" on a system. this is probably good enough to get the PR merged, but i do think that generally we should make sure there are some testing steps listed out here for the "end to end" functionality, which includes vendors from compass with vendor_deleted_dates.

Comment on lines +460 to +461
result = await db.execute(duplicates_removed)
return result.scalars().all()
Copy link
Contributor

Choose a reason for hiding this comment

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

any particular reason that we're changing the functionality here? if it's just a general optimization, i understand that motivation - but i think i'd lean toward keeping this using the simple return await list_resource(System, db), because i believe this was in place for backward compatibility of this endpoint with uses in the fides CLI, etc - when it specifically did not paginate, filter, or deduplicate (or do anything besides list all the systems, raw).

granted, that backward compatibility is not well commented in the code, so if we do keep this as it was, then a nice addition would be a code comment to clarify why it's kept as list_resource, i.e. for backward compatibility reasons.

i see/know that @erosselli and @galvana worked on refactoring this endpoint a little while back, may be worth getting them to chime in quickly.

also, as more of a stylistic comment - i preferred this conditional coming at the beginning of the endpoint function, as it had been previously. if there's a branch of the function that's a "special case" and returns immediately, i'd prefer to see that at the beginning - i just find that easier to make sense of when reading the function...

Copy link
Contributor

Choose a reason for hiding this comment

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

Hey guys, yes, that's the reason we kept the non-paginated version of the system retrieval, for backwards compatibility. I also agree with @adamsachs's comment about having this higher up so it's a little more obvious that there's a possible early return.

tests/ctl/core/test_api.py Show resolved Hide resolved
"vendor_deleted_date, expected_systems_count, show_deleted",
[
(datetime.now() - timedelta(days=1), 1, True),
(datetime.now() - timedelta(days=1), 0, None),
Copy link
Contributor

Choose a reason for hiding this comment

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

nit - reads a bit weird to me that the value here is True or None, although i know that None is falsey 😛

Suggested change
(datetime.now() - timedelta(days=1), 0, None),
(datetime.now() - timedelta(days=1), 0, False),

Copy link
Contributor Author

Choose a reason for hiding this comment

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

More than falsey, I was trying to test the parameter being not present.

@andres-torres-marroquin andres-torres-marroquin merged commit 3565c6f into main Dec 4, 2024
37 checks passed
@andres-torres-marroquin andres-torres-marroquin deleted the andres/HJ-97 branch December 4, 2024 18:39
andres-torres-marroquin added a commit that referenced this pull request Dec 4, 2024
Copy link

cypress bot commented Dec 4, 2024

fides    Run #11266

Run Properties:  status check passed Passed #11266  •  git commit 3565c6fe4e: HJ-97 - Update systems endpoint to filter vendor deleted systems (#5553)
Project fides
Branch Review main
Run status status check passed Passed #11266
Run duration 00m 58s
Commit git commit 3565c6fe4e: HJ-97 - Update systems endpoint to filter vendor deleted systems (#5553)
Committer Andres Torres
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
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.

3 participants