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

Sailthru Integration: ignore valid 400 for user not existing #5145

Merged
merged 8 commits into from
Aug 6, 2024

Conversation

SteveDMurphy
Copy link
Contributor

Closes FIDES-1082

Description Of Changes

  • Ignores 400 returned when a user cannot be found

Code Changes

  • Ignore the 400 for a user not found

Steps to Confirm

  • Tested with client in deployment

Pre-Merge Checklist

  • All CI Pipelines Succeeded
  • 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
  • Issue Requirements are Met
  • Relevant Follow-Up Issues Created
  • Update CHANGELOG.md
  • For API changes, the Postman collection has been updated
  • If there are any 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!

Copy link

vercel bot commented Jul 31, 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 Aug 6, 2024 9:23pm

@SteveDMurphy SteveDMurphy force-pushed the SteveDMurphy-fides-1082-ignore-400-sailthru branch from 457e78f to 754d44a Compare July 31, 2024 16:00
Copy link

cypress bot commented Jul 31, 2024



Test summary

4 0 0 0


Run details

Project fides
Status Passed
Commit 96cb6e8c7f ℹ️
Started Aug 6, 2024 9:35 PM
Ended Aug 6, 2024 9:35 PM
Duration 00:36 💡
OS Linux Ubuntu -
Browser Electron 106

View run in Cypress Cloud ➡️


This comment has been generated by cypress-bot as a result of this project's GitHub integration settings. You can manage this integration in this project's settings in the Cypress Cloud

@SteveDMurphy SteveDMurphy self-assigned this Jul 31, 2024
@@ -67,10 +67,12 @@ def marigold_engage_user_read(
method=HTTPMethod.GET,
path="/user",
query_params=signed_payload(secrets, payload),
)
),
ignore_errors=[400],
Copy link
Contributor

Choose a reason for hiding this comment

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

Because we're using a request_override for the user read, we can't define ignore_errors on the SaaS config, it needs to be defined on the client.send inside the request override. It's possible for a request override function to make multiple client.send calls so if we define ignore_errors at the SaaS config level, we couldn't programmatically determine which client.send to apply that to.

Copy link
Contributor

Choose a reason for hiding this comment

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

We could define a variable that makes explicit for future programmers that we are ignoring the 400 error because the user might not exist, and also remove a magic number/list, by defining something like

error400ForUserNotFound = [400]

Copy link
Contributor

@Vagoasdf Vagoasdf Aug 1, 2024

Choose a reason for hiding this comment

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

Also, Do we have an explanation from their docs on why an UserNotFound is a 400 error instead of a 404 ? Usually NotFound errors are 404.
Nevermind, found the reference on the Docs. I'ts odd that they override the usual 404 error.
Maybe we should check for the specific error message "User not found with {KEY}", just so we dont blank accept any 400 error

It did feel odd to see a 400 for this instead of the 404. Happy to see if we can dig in a bit more to ensure other errors aren't also being ignored. Sounds like that might be the case with the custom override we need to account for based on what @galvana was saying 👍🏽

Copy link
Contributor

Choose a reason for hiding this comment

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

Its better now. But i still think we should rename the variable, just so we have more clarity on what type of "400" error are we ignoring

Copy link

codecov bot commented Aug 1, 2024

Codecov Report

Attention: Patch coverage is 28.57143% with 10 lines in your changes missing coverage. Please review.

Project coverage is 86.46%. Comparing base (baa3ea1) to head (ded38d8).

Files Patch % Lines
...plementations/marigold_engage_request_overrides.py 28.57% 10 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #5145      +/-   ##
==========================================
- Coverage   86.49%   86.46%   -0.03%     
==========================================
  Files         359      359              
  Lines       22484    22495      +11     
  Branches     2979     2981       +2     
==========================================
+ Hits        19448    19451       +3     
- Misses       2503     2511       +8     
  Partials      533      533              

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

Copy link
Contributor

@Vagoasdf Vagoasdf left a comment

Choose a reason for hiding this comment

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

I have some doubts after double checking the documentation on Error Codes for Marigold . This implementation allows for all 400 errors to pass, but there might be a few of them, like Missing required parameter or account not enabled for lookup that we wouldn't want to ignore. Maybe we can check directly the error message, and allow/deny success acordding to that?

@@ -67,10 +67,12 @@ def marigold_engage_user_read(
method=HTTPMethod.GET,
path="/user",
query_params=signed_payload(secrets, payload),
)
),
ignore_errors=[400],
Copy link
Contributor

Choose a reason for hiding this comment

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

We could define a variable that makes explicit for future programmers that we are ignoring the 400 error because the user might not exist, and also remove a magic number/list, by defining something like

error400ForUserNotFound = [400]

@@ -67,10 +67,12 @@ def marigold_engage_user_read(
method=HTTPMethod.GET,
path="/user",
query_params=signed_payload(secrets, payload),
)
),
ignore_errors=[400],
Copy link
Contributor

@Vagoasdf Vagoasdf Aug 1, 2024

Choose a reason for hiding this comment

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

Also, Do we have an explanation from their docs on why an UserNotFound is a 400 error instead of a 404 ? Usually NotFound errors are 404.
Nevermind, found the reference on the Docs. I'ts odd that they override the usual 404 error.
Maybe we should check for the specific error message "User not found with {KEY}", just so we dont blank accept any 400 error

It did feel odd to see a 400 for this instead of the 404. Happy to see if we can dig in a bit more to ensure other errors aren't also being ignored. Sounds like that might be the case with the custom override we need to account for based on what @galvana was saying 👍🏽

@galvana galvana marked this pull request as ready for review August 6, 2024 01:31
@galvana galvana requested a review from a team as a code owner August 6, 2024 01:31
Copy link
Contributor

@Vagoasdf Vagoasdf left a comment

Choose a reason for hiding this comment

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

Looks a lot better! Just small improvements in order to avoid 400 as a magic number

@@ -67,10 +67,12 @@ def marigold_engage_user_read(
method=HTTPMethod.GET,
path="/user",
query_params=signed_payload(secrets, payload),
)
),
ignore_errors=[400],
Copy link
Contributor

Choose a reason for hiding this comment

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

Its better now. But i still think we should rename the variable, just so we have more clarity on what type of "400" error are we ignoring

@galvana galvana requested a review from Vagoasdf August 6, 2024 17:42
@galvana galvana merged commit ac0d323 into main Aug 6, 2024
14 checks passed
@galvana galvana deleted the SteveDMurphy-fides-1082-ignore-400-sailthru branch August 6, 2024 21:23
Copy link

cypress bot commented Aug 6, 2024



Test summary

4 0 0 0


Run details

Project fides
Status Passed
Commit ac0d323
Started Aug 6, 2024 9:35 PM
Ended Aug 6, 2024 9:36 PM
Duration 00:36 💡
OS Linux Ubuntu -
Browser Electron 106

View run in Cypress Cloud ➡️


This comment has been generated by cypress-bot as a result of this project's GitHub integration settings. You can manage this integration in this project's settings in the Cypress Cloud

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