From 9b7c8830bb028ef36f22bfcb68aaf284ea229afd Mon Sep 17 00:00:00 2001 From: Stephane Geneix <147216312+stephane-airbyte@users.noreply.github.com> Date: Wed, 25 Oct 2023 10:01:01 -0700 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20=20fix=20error=20message=20for?= =?UTF-8?q?=20postgres=20standby=20error=201/2(#31792)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- airbyte-cdk/java/airbyte-cdk/build.gradle | 7 +++-- .../util/ConnectorExceptionUtil.java | 29 +++++++++---------- .../src/main/resources/version.properties | 2 +- 3 files changed, 19 insertions(+), 19 deletions(-) diff --git a/airbyte-cdk/java/airbyte-cdk/build.gradle b/airbyte-cdk/java/airbyte-cdk/build.gradle index a3b159aea55d..97cb84185b05 100644 --- a/airbyte-cdk/java/airbyte-cdk/build.gradle +++ b/airbyte-cdk/java/airbyte-cdk/build.gradle @@ -28,10 +28,13 @@ subprojects { subproject -> artifact subproject.tasks.testFixturesJar } } + // This repository is only defined and used in the context of an artifact publishing + // It's different from the 'airbyte-public-jars' defined in settings.graddle only in its omission + // of the 'public' directory. Any artifacts publish here will be available in the 'airbyte-public-jars' repo repositories { maven { - name 'airbyte-public-jars' - url 'https://airbyte.mycloudrepo.io/repositories/airbyte-public-jars/' + name 'airbyte-repo' + url 'https://airbyte.mycloudrepo.io/repositories/airbyte-public-jars/' credentials { username System.getenv('CLOUDREPO_USER') password System.getenv('CLOUDREPO_PASSWORD') diff --git a/airbyte-cdk/java/airbyte-cdk/core/src/main/java/io/airbyte/cdk/integrations/util/ConnectorExceptionUtil.java b/airbyte-cdk/java/airbyte-cdk/core/src/main/java/io/airbyte/cdk/integrations/util/ConnectorExceptionUtil.java index d06267d4851c..9f4ae86cfe78 100644 --- a/airbyte-cdk/java/airbyte-cdk/core/src/main/java/io/airbyte/cdk/integrations/util/ConnectorExceptionUtil.java +++ b/airbyte-cdk/java/airbyte-cdk/core/src/main/java/io/airbyte/cdk/integrations/util/ConnectorExceptionUtil.java @@ -15,7 +15,6 @@ import java.util.Collection; import java.util.List; import java.util.Locale; -import java.util.function.Predicate; import org.apache.commons.lang3.exception.ExceptionUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -30,15 +29,13 @@ public class ConnectorExceptionUtil { public static final String COMMON_EXCEPTION_MESSAGE_TEMPLATE = "Could not connect with provided configuration. Error: %s"; static final String RECOVERY_CONNECTION_ERROR_MESSAGE = "We're having issues syncing from a Postgres replica that is configured as a hot standby server. " + - "Please see https://docs.airbyte.com/integrations/sources/postgres/#sync-data-from-postgres-hot-standby-server for options and workarounds"; + "Please see https://go.airbyte.com/pg-hot-standby-error-message for options and workarounds"; public static final List HTTP_AUTHENTICATION_ERROR_CODES = ImmutableList.of(401, 403); - private static final List> configErrorPredicates = - List.of(getConfigErrorPredicate(), getConnectionErrorPredicate(), - isRecoveryConnectionExceptionPredicate(), isUnknownColumnInFieldListException()); public static boolean isConfigError(final Throwable e) { - return configErrorPredicates.stream().anyMatch(predicate -> predicate.test(e)); + return isConfigErrorException(e) || isConnectionError(e) || + isRecoveryConnectionException(e) || isUnknownColumnInFieldListException(e); } public static String getDisplayMessage(final Throwable e) { @@ -46,9 +43,9 @@ public static String getDisplayMessage(final Throwable e) { return ((ConfigErrorException) e).getDisplayMessage(); } else if (e instanceof final ConnectionErrorException connEx) { return ErrorMessage.getErrorMessage(connEx.getStateCode(), connEx.getErrorCode(), connEx.getExceptionMessage(), connEx); - } else if (isRecoveryConnectionExceptionPredicate().test(e)) { + } else if (isRecoveryConnectionException(e)) { return RECOVERY_CONNECTION_ERROR_MESSAGE; - } else if (isUnknownColumnInFieldListException().test(e)) { + } else if (isUnknownColumnInFieldListException(e)) { return e.getMessage(); } else { return String.format(COMMON_EXCEPTION_MESSAGE_TEMPLATE, e.getMessage() != null ? e.getMessage() : ""); @@ -88,22 +85,22 @@ public static void logAllAndThrowFirst(final String initia } } - private static Predicate getConfigErrorPredicate() { - return e -> e instanceof ConfigErrorException; + private static boolean isConfigErrorException(Throwable e) { + return e instanceof ConfigErrorException; } - private static Predicate getConnectionErrorPredicate() { - return e -> e instanceof ConnectionErrorException; + private static boolean isConnectionError(Throwable e) { + return e instanceof ConnectionErrorException; } - private static Predicate isRecoveryConnectionExceptionPredicate() { - return e -> e instanceof SQLException && e.getMessage() + private static boolean isRecoveryConnectionException(Throwable e) { + return e instanceof SQLException && e.getMessage() .toLowerCase(Locale.ROOT) .contains("due to conflict with recovery"); } - private static Predicate isUnknownColumnInFieldListException() { - return e -> e instanceof SQLSyntaxErrorException + private static boolean isUnknownColumnInFieldListException(Throwable e) { + return e instanceof SQLSyntaxErrorException && e.getMessage() .toLowerCase(Locale.ROOT) .contains("unknown column") diff --git a/airbyte-cdk/java/airbyte-cdk/core/src/main/resources/version.properties b/airbyte-cdk/java/airbyte-cdk/core/src/main/resources/version.properties index 87d78c6caaa1..9e1dcf074f45 100644 --- a/airbyte-cdk/java/airbyte-cdk/core/src/main/resources/version.properties +++ b/airbyte-cdk/java/airbyte-cdk/core/src/main/resources/version.properties @@ -1 +1 @@ -version=0.1.12 +version=0.1.13