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

Feature/error handling #2271

Open
wants to merge 21 commits into
base: master
Choose a base branch
from

Conversation

Trianz-Akshay
Copy link
Contributor

Issue #, if available:
#2256 error handling improvement
Description of changes:
This PR contains error handling changes for connectors with athena-federation-sdk and athena-jdbc :

Snowflake
Redshift
OpenSearch
DynamoDB

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

…ift-snowflake' into feature/error_handling_all
}
else if (response.getActiveShards() == 0) {
throw new RuntimeException("There are no active shards for index (" + index + ").");
throw new AthenaConnectorException("There are no active shards for index (" + index + ").", new ErrorDetails().withErrorCode(FederationSourceErrorCode.InternalServiceException.toString()));
}
else if (response.getStatus() == ClusterHealthStatus.RED) {

Choose a reason for hiding this comment

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

How are we handling access denied?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

AwsRestHighLevelClient only returns the client. the client will be returning a response in ElasticsearchMetadataHandler. so I think that will throw access denied on the metadata handler class as there is not any exclusive exception thrown.

}

return domainMap;
}
catch (Exception error) {
throw new RuntimeException("Unable to create domain map: " + error.getMessage(), error);

Choose a reason for hiding this comment

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

Why would this error occur?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Removed this. As it was present there already so changed only exception.

@@ -129,13 +132,13 @@ private Map<String, String> getDomainMapFromAmazonElasticsearch()
}

if (domainMap.isEmpty()) {
throw new RuntimeException("Amazon Elasticsearch Service has no domain information for user.");
throw new AthenaConnectorException("Amazon Elasticsearch Service has no domain information for user.", new ErrorDetails().withErrorCode(FederationSourceErrorCode.EntityNotFoundException.toString()));

Choose a reason for hiding this comment

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

This is more an invalid input?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Replaced.

@@ -153,20 +156,20 @@ private Map<String, String> getDomainMapFromAmazonElasticsearch()
private Map<String, String> getDomainMapFromEnvironmentVar(String domainMapping)
{
if (domainMapping == null || domainMapping.isEmpty()) {
throw new RuntimeException("Unable to create domain map: Empty or null value found in DomainMapping.");
throw new AthenaConnectorException("Unable to create domain map: Empty or null value found in DomainMapping.", new ErrorDetails().withErrorCode(FederationSourceErrorCode.EntityNotFoundException.toString()));

Choose a reason for hiding this comment

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

This is more an invalid input

Copy link
Contributor Author

Choose a reason for hiding this comment

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

updated.

}
Map<String, String> domainMap;
try {
domainMap = domainSplitter.split(domainMapping);
}
catch (Exception error) {
// Intentional obfuscation of error message as it may contain sensitive info (e.g. username/password).
throw new RuntimeException("Unable to create domain map: DomainMapping Parsing error.");
throw new AthenaConnectorException("Unable to create domain map: DomainMapping Parsing error.", new ErrorDetails().withErrorCode(FederationSourceErrorCode.InternalServiceException.toString()));

Choose a reason for hiding this comment

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

this is also an invalid input

Copy link
Contributor Author

Choose a reason for hiding this comment

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

updated.

}

if (domainMap.isEmpty()) {
// Intentional obfuscation of error message: domainMapping contains sensitive info (e.g. username/password).
throw new RuntimeException("Unable to create domain map: Invalid DomainMapping value.");
throw new AthenaConnectorException("Unable to create domain map: Invalid DomainMapping value.", new ErrorDetails().withErrorCode(FederationSourceErrorCode.InvalidResponseException.toString()));

Choose a reason for hiding this comment

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

why did invalid response?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

updated to InvalidInput

@yipez-spec
Copy link
Contributor

Can we break this pull request into individual connector and sdk? This is a huge pull request and hard to review

@Trianz-Akshay
Copy link
Contributor Author

Trianz-Akshay commented Sep 19, 2024

@yipez-spec Below are the PRs raised for individual moduls:
SDK - #2278
JDBC - #2276
Elasticsearch - #2279
DynamoDB - #2277
Redshift - #2275
Snowflake - #2274

I have incorporated the review feedback given by @aaronsven . Please review the above PRs.
Please confirm if this PR should be closed.

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.

4 participants