diff --git a/airbyte-cdk/java/airbyte-cdk/README.md b/airbyte-cdk/java/airbyte-cdk/README.md index da8adc9ce3da..b7cd3a8853d4 100644 --- a/airbyte-cdk/java/airbyte-cdk/README.md +++ b/airbyte-cdk/java/airbyte-cdk/README.md @@ -174,6 +174,7 @@ corresponds to that version. | Version | Date | Pull Request | Subject | |:-----------|:-----------|:-------------------------------------------------------------|:---------------------------------------------------------------------------------------------------------------------------------------------------------------| +| 0.44.17 | 2024-08-27 | [\#44832](https://github.com/airbytehq/airbyte/pull/44832) | Fix issues where some error messages with upper cases do not get matched by the error translation framework. | | 0.44.16 | 2024-08-22 | [\#44505](https://github.com/airbytehq/airbyte/pull/44505) | Destinations: add sqlgenerator testing for mixed-case stream name | | 0.44.15 | ?????????? | [\#?????](https://github.com/airbytehq/airbyte/pull/?????) | ????? | | 0.44.14 | 2024-08-19 | [\#42503](https://github.com/airbytehq/airbyte/pull/42503) | Destinations (refreshes) - correctly detect existing raw/final table of the correct generation during truncate sync | diff --git a/airbyte-cdk/java/airbyte-cdk/core/src/main/kotlin/io/airbyte/cdk/integrations/util/ConnectorExceptionHandler.kt b/airbyte-cdk/java/airbyte-cdk/core/src/main/kotlin/io/airbyte/cdk/integrations/util/ConnectorExceptionHandler.kt index d050994f5275..38ec13a3a223 100644 --- a/airbyte-cdk/java/airbyte-cdk/core/src/main/kotlin/io/airbyte/cdk/integrations/util/ConnectorExceptionHandler.kt +++ b/airbyte-cdk/java/airbyte-cdk/core/src/main/kotlin/io/airbyte/cdk/integrations/util/ConnectorExceptionHandler.kt @@ -14,7 +14,6 @@ import io.airbyte.protocol.models.v0.AirbyteMessage import io.github.oshai.kotlinlogging.KotlinLogging import java.util.function.Consumer import java.util.regex.Pattern -import java.util.regex.PatternSyntaxException import kotlin.system.exitProcess import org.jetbrains.annotations.VisibleForTesting @@ -33,22 +32,11 @@ data class ConnectorErrorProfile( val sampleInternalMessage: String, val referenceLinks: List = emptyList(), ) { + val regexPattern: Pattern = Pattern.compile(regexMatchingPattern, Pattern.CASE_INSENSITIVE) init { - require(isValidRegex(regexMatchingPattern)) { - "regexMatchingPattern is not a valid regular expression string" - } require(externalMessage.isNotBlank()) { "externalMessage must not be blank" } require(sampleInternalMessage.isNotBlank()) { "sampleInternalMessage must not be blank" } } - - private fun isValidRegex(regexString: String): Boolean { - return try { - Pattern.compile(regexString) - true - } catch (e: PatternSyntaxException) { - false - } - } } /** @@ -144,10 +132,8 @@ open class ConnectorExceptionHandler { */ open fun translateConnectorSpecificErrorMessage(e: Throwable?): String? { if (e == null) return null - for (error in connectorErrorDictionary) { - if (e.message?.lowercase()?.matches(error.regexMatchingPattern.toRegex())!!) - return error.externalMessage - } + for (error in connectorErrorDictionary) if (error.regexPattern.matcher(e.message).matches()) + return error.externalMessage return null } @@ -179,13 +165,10 @@ open class ConnectorExceptionHandler { return true } - for (error in connectorErrorDictionary) { - if ( - error.failureType == failureType && - e!!.message?.matches(error.regexMatchingPattern.toRegex())!! - ) - return true - } + for (error in connectorErrorDictionary) if ( + error.failureType == failureType && error.regexPattern.matcher(e!!.message).matches() + ) + return true return false } @@ -194,14 +177,14 @@ open class ConnectorExceptionHandler { * a known transient exception, a config exception, or an exception whose error messages have been * stored as part of the error profile in the error dictionary. * */ + @VisibleForTesting private fun isRecognizableError(e: Throwable?): Boolean { if (e?.message == null) return false if (e is TransientErrorException || e is ConfigErrorException) { return true } - for (error in connectorErrorDictionary) { - if (e.message!!.matches(error.regexMatchingPattern.toRegex())) return true - } + for (error in connectorErrorDictionary) if (error.regexPattern.matcher(e.message).matches()) + return true return false } } 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 e42b83d0c73d..a34469e9e2d8 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.44.16 +version=0.44.17