-
Notifications
You must be signed in to change notification settings - Fork 4.5k
cdk: do not call init_uncaught_exception_handler
from modules' root
#14892
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
cdk: do not call init_uncaught_exception_handler
from modules' root
#14892
Conversation
…nit__ and Destination.run_cmd
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🔥 1 PR per day streak continues
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice! Just left a couple minor suggestions
@@ -136,6 +137,13 @@ def __eq__(self, other): | |||
|
|||
|
|||
class TestRun: | |||
def test_run_cmd(self, mocker, destination: Destination): | |||
mocker.patch.object(destination_module, "init_uncaught_exception_handler") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: it would be more appropriate to patch/assert on the exception_handler
module directly instead of the method being exposed within Destination or AirbyteEntrypoint
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In the context of this test, I think it's a better practice to mock what's being used by the function under test: the init_uncaught_exception_handler
object available in destination
module namespace and not the actual function in the exception_handler
module. This test is not a concern, but patching the function could lead to unexpected side effects. Moreover, it allows us to change the module in which init_uncaught_exception_handler
is declared without refactoring the test 😄
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🚀
/publish-cdk dry-run=false
|
What
Closing #14453
Calling
init_uncaught_exception_handler
from the module root affects the stack trace of projects using the CDK's model.How
To overcome this problem I moved the call to
init_uncaught_exception_handler
when real execution logic happens: inAirbyteEntrypoint.__init__
for sources and inDestination.run_cmd
for destinations.