Skip to content

Commit

Permalink
🐛 fix error message for postgres standby error 1/2(#31792)
Browse files Browse the repository at this point in the history
  • Loading branch information
stephane-airbyte authored Oct 25, 2023
1 parent 8d60177 commit 9b7c883
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 19 deletions.
7 changes: 5 additions & 2 deletions airbyte-cdk/java/airbyte-cdk/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -30,25 +29,23 @@ 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<Integer> HTTP_AUTHENTICATION_ERROR_CODES = ImmutableList.of(401, 403);
private static final List<Predicate<Throwable>> 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) {
if (e instanceof ConfigErrorException) {
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() : "");
Expand Down Expand Up @@ -88,22 +85,22 @@ public static <T extends Throwable> void logAllAndThrowFirst(final String initia
}
}

private static Predicate<Throwable> getConfigErrorPredicate() {
return e -> e instanceof ConfigErrorException;
private static boolean isConfigErrorException(Throwable e) {
return e instanceof ConfigErrorException;
}

private static Predicate<Throwable> getConnectionErrorPredicate() {
return e -> e instanceof ConnectionErrorException;
private static boolean isConnectionError(Throwable e) {
return e instanceof ConnectionErrorException;
}

private static Predicate<Throwable> 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<Throwable> isUnknownColumnInFieldListException() {
return e -> e instanceof SQLSyntaxErrorException
private static boolean isUnknownColumnInFieldListException(Throwable e) {
return e instanceof SQLSyntaxErrorException
&& e.getMessage()
.toLowerCase(Locale.ROOT)
.contains("unknown column")
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
version=0.1.12
version=0.1.13

0 comments on commit 9b7c883

Please sign in to comment.