-
Notifications
You must be signed in to change notification settings - Fork 3.8k
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
AirbyteLib: Exception Handling #34488
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎ 1 Ignored Deployment
|
@flash1293 - A few tests are broken but I wanted to open this for your review and for our discussion on the design proposals here. |
…n' into aj/airbyte-lib/custom-exceptions
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.
Love the design - this is set up really well for the future! I started leaving nits of which information should be provided in which place and the semantics of different error classes, but I will hold off for now as it seems like you are still fixing.
@@ -123,7 +130,9 @@ def _get_connector_path(self) -> Path: | |||
def _run_subprocess_and_raise_on_failure(self, args: list[str]) -> None: | |||
result = subprocess.run(args, check=False) | |||
if result.returncode != 0: | |||
raise Exception(f"Install process exited with code {result.returncode}") | |||
raise exc.AirbyteConnectorInstallationError from exc.AirbyteSubprocessFailedError( | |||
exit_code=result.returncode |
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.
should we add stdout/stderr and args as context here?
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.
I left it out to avoid risk - and with a focus on parity. But yes, definitely we can add in the future. 👍
raise Exception( | ||
f"Connector {self.metadata.name} is not available - " | ||
f"venv {venv_name} does not exist" | ||
raise exc.AirbyteConnectorNotFoundError( |
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.
This specific branch is actionable - we can give a guidance of either install yourself or set the install_if_missing option
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.
Added!
@flash1293 - Thanks for the review! I will incorporate your suggestions. Just as fyi, in some cases, I knew I could add more context but I was trying to limit scope - with the objective of getting parity without adding potential for new bugs/issues. One nice thing about this model is that it's easily extensible. We can find new attributes to log in the exception and add them incrementally without much added effort. I imagine as we see these raised 'in the wild', we'll see opportunities to improve the debugging experience for us and users. I've also fixed all tests - so you can complete the review if you had anything you wanted to add. This PR fixes an unrelated bug that was preventing tests from passing. I've merged it into this branch so that tests are green. |
@flash1293 - One thing to add here - a big advantage of these custom classes will be the ability to tie the exception name and message into telemetry without worrying about PII. Sometimes paths and text inputs will have user entered info, but in this implementation, we can safely expect that message, class name, and call stack file/line-nums are always safe to report. We can also add specific attributes as safe for telemetry, such as 'exit_code', which will never have PII because it is an integer. |
@flash1293 - This resolves most feedback, but not 100%. Specifically, I opted not to add stdout/stderr prints for now due to needing to retest and/or add new tests if so. We can keep adding from here though, as discussed. Merging now that tests pass, so we can keep things moving. :) |
This brings more formalized exception handling to AirbyteLib.
This handles the lint rules:
More detail in the new exceptions module. From the file docstring: