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

introduce subclasses and add more telemetry for ProgrammingErrors #1651

Merged
merged 58 commits into from
Oct 18, 2024

Conversation

sfc-gh-mchok
Copy link
Collaborator

@sfc-gh-mchok sfc-gh-mchok commented Oct 1, 2024

Pre-review checklist

  • I've confirmed that instructions included in README.md are still correct after my changes in the codebase.
  • I've added or updated automated unit tests to verify correctness of my new code.
  • I've confirmed that my changes are working by executing CLI's commands manually on MacOS.
  • I've confirmed that my changes are working by executing CLI's commands manually on Windows.
  • I've confirmed that my changes are up-to-date with the target branch.
  • I've described my changes in the release notes.
  • I've added or updated integration tests to verify correctness of my new code.
  • I've described my changes in the section below.

Changes description

  1. Implemented custom errors derived from ClickException to replace places where we raise ProgrammingError
  2. Added more telemetry (errno, sqlstate, error cause) to error events
  3. Add shared code ownership to a couple of shared test files

@sfc-gh-mchok sfc-gh-mchok marked this pull request as ready for review October 3, 2024 17:54
@sfc-gh-mchok sfc-gh-mchok requested review from a team as code owners October 3, 2024 17:54
@sfc-gh-mchok sfc-gh-mchok changed the title introduce subclasses for ProgrammingErrors and add more telemetry introduce subclasses and add more telemetry for ProgrammingErrors Oct 3, 2024
src/snowflake/cli/_app/telemetry.py Outdated Show resolved Hide resolved
src/snowflake/cli/_app/telemetry.py Outdated Show resolved Hide resolved
src/snowflake/cli/_app/telemetry.py Outdated Show resolved Hide resolved
tests_integration/nativeapp/test_telemetry_errors.py Outdated Show resolved Hide resolved
tests_integration/nativeapp/test_telemetry_errors.py Outdated Show resolved Hide resolved
tests_integration/nativeapp/test_telemetry_errors.py Outdated Show resolved Hide resolved
src/snowflake/cli/_app/telemetry.py Outdated Show resolved Hide resolved
src/snowflake/cli/api/entities/utils.py Outdated Show resolved Hide resolved
tests/app/test_telemetry.py Outdated Show resolved Hide resolved
src/snowflake/cli/_app/telemetry.py Outdated Show resolved Hide resolved
src/snowflake/cli/_app/telemetry.py Outdated Show resolved Hide resolved
src/snowflake/cli/_app/telemetry.py Outdated Show resolved Hide resolved
src/snowflake/cli/_plugins/nativeapp/exceptions.py Outdated Show resolved Hide resolved
src/snowflake/cli/api/entities/utils.py Outdated Show resolved Hide resolved
src/snowflake/cli/api/exceptions.py Outdated Show resolved Hide resolved
tests_integration/conftest.py Outdated Show resolved Hide resolved
tests_integration/conftest.py Outdated Show resolved Hide resolved
Comment on lines 225 to 229
class ShowSpecificObjectMultipleRowsError(ClickException):
def __init__(self, show_obj_query: str):
super().__init__(
f"Received multiple rows from result of SQL statement: {show_obj_query}. Usage of 'show_specific_object' may not be properly scoped."
)
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this user facing error? How should they act if they see "Usage of 'show_specific_object' may not be properly scoped." message?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Just looking through the code, it seems like this is an error that is meant for us who is using the function, not the end users, and as the message says we need to make sure that our usage of this function is properly scoped (e.g. passing the right parameters)

@sfc-gh-turbaszek
Copy link
Contributor

Should we use generic_sql_error_handler for SqlExecutionMixin_execute_string or in SnowTyper.post_execute where we rewrite db errors into click exceptions?

@sfc-gh-mchok sfc-gh-mchok changed the title introduce subclasses and add more telemetry for ProgrammingErrors refactor ProgrammingErrors being raised into subclasses Oct 15, 2024
@sfc-gh-mchok
Copy link
Collaborator Author

sfc-gh-mchok commented Oct 15, 2024

Should we use generic_sql_error_handler for SqlExecutionMixin_execute_string or in SnowTyper.post_execute where we rewrite db errors into click exceptions?

@sfc-gh-turbaszek We are currently in the process of refactoring our error handling and one of our goals is actually to phase out the usage of generic_sql_error_handler since we want our error handling to be more specific and take into the context of when the error happened in order to provide more rich error messages/handling

sfc-gh-mchok and others added 10 commits October 15, 2024 15:24
…li exceptions, add catch for post deploy scripts
Updates tests in `test_manager.py` to use a v2 test project and call out to the v2 entities directly instead of going through the `NativeAppManager`. I've kept the diff as simple as possible and avoided introducing too many helpers or reorganizing the code, that can be done separately if necessary (the top priority is to just work towards removing `NativeAppManager` and all these static methods first).
Convert package post-deploy tests and one skipped integration tests to remove use of `NativeAppManager`.
This reverts commit 1b7072f.

Since the PR that once depended on this one is now branching off main, we are re-adding the telemetry additions.
@sfc-gh-mchok sfc-gh-mchok changed the title refactor ProgrammingErrors being raised into subclasses introduce subclasses and add more telemetry for ProgrammingErrors Oct 17, 2024
@sfc-gh-turbaszek sfc-gh-turbaszek merged commit ac6d4d1 into main Oct 18, 2024
18 checks passed
@sfc-gh-turbaszek sfc-gh-turbaszek deleted the mchok-improve-ProgrammingError branch October 18, 2024 09:02
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.

6 participants