Skip to content

bulk-cdk: add ExceptionClassifier, revamp exception handling #44608

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

Merged
merged 1 commit into from
Aug 23, 2024

Conversation

postamar
Copy link
Contributor

@postamar postamar commented Aug 23, 2024

What

This change is required for CAT tests to pass for connectors built using the Bulk CDK.
This change also paves the way to declarative rules-based exception handling.

Informs https://github.com/airbytehq/airbyte-internal-issues/issues/9373

How

The change centers around the introduction of ExceptionClassifier

Review guide

Reading through the diff in the order that github presents it is actually pretty good.

User Impact

None

Can this PR be safely reverted and rolled back?

  • YES 💚
  • NO ❌

@postamar postamar requested review from a team as code owners August 23, 2024 19:02
Copy link

vercel bot commented Aug 23, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

1 Skipped Deployment
Name Status Preview Comments Updated (UTC)
airbyte-docs ⬜️ Ignored (Inspect) Aug 23, 2024 7:02pm

@octavia-squidington-iii octavia-squidington-iii added the CDK Connector Development Kit label Aug 23, 2024
operation = operationProvider.get()!!
} catch (e: Throwable) {
throw ConfigErrorException("Failed to initialize connector operation", e)
}
Copy link
Contributor Author

@postamar postamar Aug 23, 2024

Choose a reason for hiding this comment

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

This change now causes Micronaut's instantiation of Operation to deferred to this try-catch block which handles any exceptions as ConfigErrorExceptions. This is a requirement to pass the CAT tests, there's a case in there that deliberately attempts a read with an invalid configured catalog and expects a TRACE 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.

Will this also mark system errors/other crashes as Config errors?

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 in theory. In practice, exceptions thrown at this point will be triggered by the CLI inputs exclusively.

"Failed ${operation::class} operation execution."
}
}
outputConsumer.accept(exceptionClassifier.handle(e))
Copy link
Contributor Author

Choose a reason for hiding this comment

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

The OutputConsumer no longer directly accepts exceptions, instead there's now an ExceptionClassifier which turns these exceptions into TRACE ERROR messages.

.withStatus(AirbyteConnectionStatus.Status.FAILED),
)
log.info { "Config check failed." }
return
Copy link
Contributor Author

Choose a reason for hiding this comment

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

All this SQLException logic had no business being in the general-purpose CheckOperation anyway. It's been moved to JdbcExceptionClassifier in the JDBC toolkit, where it belongs.

import java.sql.SQLException

@Replaces(ExceptionClassifier::class)
class JdbcExceptionClassifier(@Value("\${${Operation.PROPERTY}}") operationName: String) :
Copy link
Contributor

Choose a reason for hiding this comment

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

Would extending this class in the connectors be the way to implement the error framework that @theyueli added e.g. PostgresSourceExceptionHandler?

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 and no. This class such as it is exists only to maintain existing functionality, which is pretty bare bones. I didn't want to add too much stuff to this PR. However, it's not really what we want; what we want is a bunch of classifiers among which @theyueli 's (the one with ConnectorErrorProfiles) would be one of them.

I see adding functionality as the logical next step. Micronaut really unlocks a lot of possibilities here, it should be trivial to add some kind of rule definitions into a yaml file such as https://github.com/airbytehq/airbyte-enterprise/blob/master/airbyte-integrations/connectors/source-firetruck/src/main/resources/application.yml

The obvious first choice is to have some kind of rules engine that works on SQLException vendor codes.

Copy link
Contributor

@akashkulk akashkulk left a comment

Choose a reason for hiding this comment

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

Some quick questions

@postamar postamar requested a review from akashkulk August 23, 2024 21:06
@postamar
Copy link
Contributor Author

Thanks for taking a look!

@postamar postamar merged commit e297fc0 into master Aug 23, 2024
40 checks passed
@postamar postamar deleted the postamar/improved-exception-handling branch August 23, 2024 21:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CDK Connector Development Kit
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants