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

added error messages factory #15832

Closed
wants to merge 125 commits into from
Closed

Conversation

andriikorotkov
Copy link
Contributor

@andriikorotkov andriikorotkov commented Aug 22, 2022

Improve database sources and destinations error messages
When users are setting up a database connector and fail (due to misconfiguration) they are often provided a non-descriptive error message

The idea of this PR is to map common SqlState code to some human readable messages like: "Incorrect password or user name", "Incorrect host or port"
Thus user may have more information what might be wrong with provided configurations

Examples how it will look on UI:

  • mysql fail database
    2022-08-22_18-27

-postgres fail username
2022-08-22_18-29

  • snowflake fail role
    2022-08-22_18-32

  • oracle fail host
    2022-08-22_18-34

  • GCS fail bucket name
    2022-08-22_18-38

andriikorotkov and others added 30 commits April 12, 2022 17:31
…nto akorotkov/11322_error_message

# Conflicts:
#	airbyte-integrations/bases/base-java/src/main/java/io/airbyte/integrations/base/errors/ErrorMessageFactory.java
#	airbyte-integrations/bases/base-java/src/main/java/io/airbyte/integrations/base/errors/utils/ConnectorType.java
@airbytehq airbytehq deleted a comment from github-actions bot Aug 26, 2022
@airbytehq airbytehq deleted a comment from github-actions bot Aug 26, 2022
@andriikorotkov andriikorotkov temporarily deployed to more-secrets August 26, 2022 09:25 Inactive
@andriikorotkov
Copy link
Contributor Author

@grishick the tests for some connectors fail not because of my changes, but because for most of them the changes were mergrd without running the tests. For example, for redshift-destination, no changes were added to secrets in Google Secret Manager. For mysql-destination-strict-encrypt - no changes were added to the transformation of types (when added to mysql-destination they were not added here) and several more connectors with small errors.

Copy link
Contributor

@ryankfu ryankfu left a comment

Choose a reason for hiding this comment

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

There's a few things that still need to be reviewed, the things that seem important are mainly on:

  • removing the use of var especially in areas where the code explicitly defines a type
  • provide a link to each of the connectors state code since it wouldn't be super useful to report a state code for a connector only for ourselves to have difficult finding these codes
  • remove the MySqlTestDataComparator work since that does not seem relevant to the error messages work

If there's a viewpoint that wasn't clear, let's work together to get this over the finish line. There's a lot a great work here and would love for this to benefit our users

if (!databaseNames.contains(databaseName) && !databaseName.equals(database.getName())) {
throw new MongodbDatabaseException(databaseName);
}
return new AirbyteConnectionStatus().withStatus(AirbyteConnectionStatus.Status.SUCCEEDED);
} catch (final ConnectionErrorException e) {
var messages = getErrorMessage(e.getStateCode(), e.getErrorCode(), e.getExceptionMessage(), e);
Copy link
Contributor

Choose a reason for hiding this comment

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

Unless I'm mistaken, isn't it possible for ConnectionErrorException to be created with the constructor ConnectionErrorException(errorMessage) and so e.getErrorCode() will not exist?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, that's right, it's possible. But in processing, in the ErrorMessage.getErrorMessage method, I'll process it, and if the error code is empty, it won't change the readability of the processed error message.

Copy link
Contributor

Choose a reason for hiding this comment

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

Wouldn't that mean that you can be passing in an uninitialized int into getErrorMessage? That would cause an error cause in MongoDbSource you create a new ConnectionErrorException(String exceptionMessage) but that does not include an errorCode

When I tested this quick snipped out in my IDE this was giving my an error compiling which mimics how getErrorMessage works, correct me if I'm wrong

  @Test
  void testUninitialzedIntPassed() {
    final int number;
    System.out.println(runTest("hi", number, "world"));
  }

  public String runTest(final String first, final int num, final String second) {
    final String temp = num == 0 ? "" : " TEST";
    return first + temp + second;
  };

((ObjectNode) config).put(JdbcUtils.HOST_KEY, "localhost2");
final AirbyteConnectionStatus actual = source.check(config);
assertEquals(Status.FAILED, actual.getStatus());
assertTrue(actual.getMessage().contains("State code: 28000; Error code: 200028;"));
}

@Override
Copy link
Contributor

Choose a reason for hiding this comment

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

It seems the messaging was lost, the comment was not intended to say that Charles has a PR that would potentially conflict with the changes here. The message was that here are the list of tests that should be covered in each of the different connectors. So namely invalid:

  • host
  • port
  • username
  • password
  • database
  • schema

The reason for asking for how the error/state codes were found is because some of the mongodb tests are asserting something like

assertTrue(airbyteConnectionStatus.getMessage().contains("State code: -4"));

However from the standpoint of debugging, if someone wanted to look up what mongo db state code is how can it be determined that they're the right state codes? For instance looking up state codes for mongodb I could only find these state code but none of them match -4. It begs the question, how would these state codes be useful if documentation from mongodb doesn't match the codes in the test and what they mean?

}

@Override
protected boolean compareDateTimeValues(String expectedValue, String actualValue) {
Copy link
Contributor

Choose a reason for hiding this comment

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

How is this work relevant to the error messages work?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

this logic is added here in the strict-encrypt connector from the main connector. Here is the number of the pull request and its name in which it was done - [15245] Destination-mysql: fixed normalization tests after changes in python part. The developer who added these changes only added them to the main connector, but forgot about strict-encrypt. Therefore, the tests will fail here, which interferes with testing and publishing.

@airbytehq airbytehq deleted a comment from github-actions bot Aug 26, 2022
@andriikorotkov andriikorotkov temporarily deployed to more-secrets August 26, 2022 11:07 Inactive
@andriikorotkov
Copy link
Contributor Author

  • remove the MySqlTestDataComparator work since that does not seem relevant to the error messages work

@ryankfu because of this part, i can't publish my changes to handle messages. This part breaks the tests and makes the normal publishing process impossible. (I try to adhere to the concept, and first run the tests there to publish without turning off the tests)

@andriikorotkov
Copy link
Contributor Author

andriikorotkov commented Aug 26, 2022

/test connector=connectors/destination-redshift

🕑 connectors/destination-redshift https://github.com/airbytehq/airbyte/actions/runs/2933553086
✅ connectors/destination-redshift https://github.com/airbytehq/airbyte/actions/runs/2933553086
Python tests coverage:

Name                                                              Stmts   Miss  Cover
-------------------------------------------------------------------------------------
normalization/transform_config/__init__.py                            2      0   100%
normalization/transform_catalog/reserved_keywords.py                 13      0   100%
normalization/transform_catalog/__init__.py                           2      0   100%
normalization/destination_type.py                                    13      0   100%
normalization/__init__.py                                             4      0   100%
normalization/transform_catalog/destination_name_transformer.py     161      8    95%
normalization/transform_catalog/table_name_registry.py              174     34    80%
normalization/transform_config/transform.py                         186     49    74%
normalization/transform_catalog/utils.py                             51     14    73%
normalization/transform_catalog/dbt_macro.py                         22      7    68%
normalization/transform_catalog/catalog_processor.py                147     80    46%
normalization/transform_catalog/transform.py                         61     38    38%
normalization/transform_catalog/stream_processor.py                 589    394    33%
-------------------------------------------------------------------------------------
TOTAL                                                              1425    624    56%

Build Passed

Test summary info:

All Passed

@airbytehq airbytehq deleted a comment from github-actions bot Aug 26, 2022
@andriikorotkov andriikorotkov temporarily deployed to more-secrets August 26, 2022 12:06 Inactive
@airbytehq airbytehq deleted a comment from github-actions bot Aug 26, 2022
@andriikorotkov andriikorotkov temporarily deployed to more-secrets August 26, 2022 14:25 Inactive
@andriikorotkov
Copy link
Contributor Author

andriikorotkov commented Aug 26, 2022

/test connector=connectors/destination-postgres

🕑 connectors/destination-postgres https://github.com/airbytehq/airbyte/actions/runs/2934431801
✅ connectors/destination-postgres https://github.com/airbytehq/airbyte/actions/runs/2934431801
Python tests coverage:

Name                                                              Stmts   Miss  Cover
-------------------------------------------------------------------------------------
normalization/transform_config/__init__.py                            2      0   100%
normalization/transform_catalog/reserved_keywords.py                 13      0   100%
normalization/transform_catalog/__init__.py                           2      0   100%
normalization/destination_type.py                                    13      0   100%
normalization/__init__.py                                             4      0   100%
normalization/transform_catalog/destination_name_transformer.py     161      8    95%
normalization/transform_catalog/table_name_registry.py              174     34    80%
normalization/transform_config/transform.py                         186     49    74%
normalization/transform_catalog/utils.py                             51     14    73%
normalization/transform_catalog/dbt_macro.py                         22      7    68%
normalization/transform_catalog/catalog_processor.py                147     80    46%
normalization/transform_catalog/transform.py                         61     38    38%
normalization/transform_catalog/stream_processor.py                 589    394    33%
-------------------------------------------------------------------------------------
TOTAL                                                              1425    624    56%

Build Passed

Test summary info:

All Passed

@andriikorotkov
Copy link
Contributor Author

andriikorotkov commented Aug 26, 2022

/test connector=connectors/destination-mysql-strict-encrypt

🕑 connectors/destination-mysql-strict-encrypt https://github.com/airbytehq/airbyte/actions/runs/2934990316
✅ connectors/destination-mysql-strict-encrypt https://github.com/airbytehq/airbyte/actions/runs/2934990316
Python tests coverage:

Name                                                              Stmts   Miss  Cover
-------------------------------------------------------------------------------------
normalization/transform_config/__init__.py                            2      0   100%
normalization/transform_catalog/reserved_keywords.py                 13      0   100%
normalization/transform_catalog/__init__.py                           2      0   100%
normalization/destination_type.py                                    13      0   100%
normalization/__init__.py                                             4      0   100%
normalization/transform_catalog/destination_name_transformer.py     161      8    95%
normalization/transform_catalog/table_name_registry.py              174     34    80%
normalization/transform_config/transform.py                         186     49    74%
normalization/transform_catalog/utils.py                             51     14    73%
normalization/transform_catalog/dbt_macro.py                         22      7    68%
normalization/transform_catalog/catalog_processor.py                147     80    46%
normalization/transform_catalog/transform.py                         61     38    38%
normalization/transform_catalog/stream_processor.py                 589    394    33%
-------------------------------------------------------------------------------------
TOTAL                                                              1425    624    56%

Build Passed

Test summary info:

All Passed

@andriikorotkov
Copy link
Contributor Author

andriikorotkov commented Aug 26, 2022

@ryankfu I merged changes related to MySqlTestDataComparator in a separate pull request. Now they shouldn't get here - #16015

@airbytehq airbytehq deleted a comment from github-actions bot Aug 26, 2022
@andriikorotkov andriikorotkov temporarily deployed to more-secrets August 26, 2022 16:10 Inactive
@ryankfu
Copy link
Contributor

ryankfu commented Sep 12, 2022

Work was completed in this ticket: #16202

@ryankfu ryankfu closed this Sep 12, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment