Skip to content
This repository has been archived by the owner on Nov 30, 2022. It is now read-only.

Conversation

adamsachs
Copy link
Contributor

Purpose

Fix for #457, allows more flexibility in how SaasConnector.send can be used

Verified locally that sentry access request test is still passing, which relied on the original ignore_errors functionality (#307)

Changes

-move the conversion of errored request further up the stack

Checklist

  • Applicable documentation updated (guides, quickstart, postman collections, tutorial, fidesdemo, database diagram.
  • If docs updated (select one):
    • documentation complete, or draft/outline provided (tag docs-team to complete/review on this branch)
    • documentation issue created (tag docs-team to complete issue separately)
  • Good unit test/integration test coverage
  • This PR contains a DB migration. If checked, the reviewer should confirm with the author that the down_revision correctly references the previous migration before merging
  • The Run Unsafe PR Checks label has been applied, and checks have passed, if this PR touches any external services

Ticket

Fixes #457

Adam Sachs added 2 commits May 4, 2022 18:26
…errors. move response conversion into higher-level handling method
@adamsachs adamsachs requested a review from pattisdr May 4, 2022 22:31
@pattisdr pattisdr added the run unsafe ci checks Triggers running of unsafe CI checks label May 5, 2022
Copy link
Contributor

@pattisdr pattisdr left a comment

Choose a reason for hiding this comment

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

good improvement for using client.send for other purposes, just a suggestion around unit testing -

Comment on lines 257 to 263
if saas_request.ignore_errors and not response.ok:
logger.info(
f"Ignoring and clearing errored response with status code {response.status_code}."
)
response = Response()
response._content = b"{}" # pylint: disable=W0212

Copy link
Contributor

Choose a reason for hiding this comment

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

execute_prepared_request is getting pretty long now, and the behavior of replacing an errored response with an empty dictionary is not protected by a unit test, just an end-to-end sentry integration test.

I'd consider pulling this out into its own function then, the code comment can be the function docstring, and then a fake SaasRequest and Response can be created for unit testing just that function.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

nice suggestion @pattisdr, i'd also thought execute_prepared_request was getting rather long. i'll push an update here shortly

Copy link
Contributor Author

@adamsachs adamsachs May 5, 2022

Choose a reason for hiding this comment

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

@pattisdr - be7e5e1 has a proposed implementation for the above. i also decided to pull out an _unwrap_response_data function while i was there for similar reasons, but please let me know if you don't think that's appropriate.

and i'm still getting a feel for python static/class/instance methods, so please let me know if you don't think that these should be static methods.

@pattisdr pattisdr self-assigned this May 5, 2022
…nit tests over from integraion test file to new test_saas_connector file
@pattisdr pattisdr added run unsafe ci checks Triggers running of unsafe CI checks and removed run unsafe ci checks Triggers running of unsafe CI checks labels May 9, 2022
Copy link
Contributor

@pattisdr pattisdr left a comment

Choose a reason for hiding this comment

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

This looks good to me!

Just to clarify, it looks like this PR should fix the Stripe issues causing that remaining integration test failure? #473

@adamsachs
Copy link
Contributor Author

thanks @pattisdr! and yes, i think that's right re: #473.

i'll go ahead and merge this now.

@adamsachs adamsachs closed this May 9, 2022
@adamsachs adamsachs reopened this May 9, 2022
@adamsachs adamsachs merged commit de7244b into main May 9, 2022
@adamsachs adamsachs deleted the 457-saas-connector-improve-ignore_errors-option-to-give-the-caller-the-raw-response-object branch May 9, 2022 14:02
adamsachs added a commit to adamsachs/fidesops_forked_test that referenced this pull request May 17, 2022
…ponse (ethyca#462)

* allow SaasConnector.send to return raw response object when ignoring errors. move response conversion into higher-level handling method

* tweak log message for clarity

* split out some utility functions within saas connector. unit tests to cover the functions

* add some more test coverage for _handle_errored_response. move some unit tests over from integraion test file to new test_saas_connector file

Co-authored-by: Adam Sachs <[email protected]>
sanders41 pushed a commit that referenced this pull request Sep 22, 2022
…ponse (#462)

* allow SaasConnector.send to return raw response object when ignoring errors. move response conversion into higher-level handling method

* tweak log message for clarity

* split out some utility functions within saas connector. unit tests to cover the functions

* add some more test coverage for _handle_errored_response. move some unit tests over from integraion test file to new test_saas_connector file

Co-authored-by: Adam Sachs <[email protected]>
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
run unsafe ci checks Triggers running of unsafe CI checks
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Saas Connector] improve "ignore_errors" option to give the caller the raw response object
2 participants