From 7e38b68ba7eaad1533df27e48c8d5850ee0fc6f4 Mon Sep 17 00:00:00 2001 From: Jimmy Ma Date: Wed, 19 Oct 2022 18:33:15 -0700 Subject: [PATCH 1/2] Ensure we have protocol version on actor def reads --- .../config/persistence/ConfigRepository.java | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/airbyte-config/config-persistence/src/main/java/io/airbyte/config/persistence/ConfigRepository.java b/airbyte-config/config-persistence/src/main/java/io/airbyte/config/persistence/ConfigRepository.java index 270aaf4710f2..da7628efcb00 100644 --- a/airbyte-config/config-persistence/src/main/java/io/airbyte/config/persistence/ConfigRepository.java +++ b/airbyte-config/config-persistence/src/main/java/io/airbyte/config/persistence/ConfigRepository.java @@ -190,10 +190,13 @@ public void setFeedback(final UUID workflowId) throws JsonValidationException, C public StandardSourceDefinition getStandardSourceDefinition(final UUID sourceDefinitionId) throws JsonValidationException, IOException, ConfigNotFoundException { - return persistence.getConfig( + final StandardSourceDefinition sourceDef = persistence.getConfig( ConfigSchema.STANDARD_SOURCE_DEFINITION, sourceDefinitionId.toString(), StandardSourceDefinition.class); + // Make sure we have a default version of the Protocol. + // This corner case may happen for connectors that haven't been upgraded since we added versioning. + return sourceDef.withProtocolVersion(AirbyteProtocolVersion.getWithDefault(sourceDef.getProtocolVersion()).serialize()); } public StandardSourceDefinition getSourceDefinitionFromSource(final UUID sourceId) { @@ -302,8 +305,12 @@ public void deleteSourceDefinitionAndAssociations(final UUID sourceDefinitionId) public StandardDestinationDefinition getStandardDestinationDefinition(final UUID destinationDefinitionId) throws JsonValidationException, IOException, ConfigNotFoundException { - return persistence.getConfig(ConfigSchema.STANDARD_DESTINATION_DEFINITION, destinationDefinitionId.toString(), - StandardDestinationDefinition.class); + final StandardDestinationDefinition destDef = + persistence.getConfig(ConfigSchema.STANDARD_DESTINATION_DEFINITION, destinationDefinitionId.toString(), + StandardDestinationDefinition.class); + // Make sure we have a default version of the Protocol. + // This corner case may happen for connectors that haven't been upgraded since we added versioning. + return destDef.withProtocolVersion(AirbyteProtocolVersion.getWithDefault(destDef.getProtocolVersion()).serialize()); } public StandardDestinationDefinition getDestinationDefinitionFromDestination(final UUID destinationId) { From 5167c508bf32df7b64e8aeb45e84a566cddea748 Mon Sep 17 00:00:00 2001 From: Jimmy Ma Date: Thu, 20 Oct 2022 08:40:08 -0700 Subject: [PATCH 2/2] Fix null ref --- .../airbyte/config/persistence/ConfigRepository.java | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/airbyte-config/config-persistence/src/main/java/io/airbyte/config/persistence/ConfigRepository.java b/airbyte-config/config-persistence/src/main/java/io/airbyte/config/persistence/ConfigRepository.java index da7628efcb00..3d48f93cecaf 100644 --- a/airbyte-config/config-persistence/src/main/java/io/airbyte/config/persistence/ConfigRepository.java +++ b/airbyte-config/config-persistence/src/main/java/io/airbyte/config/persistence/ConfigRepository.java @@ -196,7 +196,10 @@ public StandardSourceDefinition getStandardSourceDefinition(final UUID sourceDef StandardSourceDefinition.class); // Make sure we have a default version of the Protocol. // This corner case may happen for connectors that haven't been upgraded since we added versioning. - return sourceDef.withProtocolVersion(AirbyteProtocolVersion.getWithDefault(sourceDef.getProtocolVersion()).serialize()); + if (sourceDef != null) { + return sourceDef.withProtocolVersion(AirbyteProtocolVersion.getWithDefault(sourceDef.getProtocolVersion()).serialize()); + } + return null; } public StandardSourceDefinition getSourceDefinitionFromSource(final UUID sourceId) { @@ -310,7 +313,10 @@ public StandardDestinationDefinition getStandardDestinationDefinition(final UUID StandardDestinationDefinition.class); // Make sure we have a default version of the Protocol. // This corner case may happen for connectors that haven't been upgraded since we added versioning. - return destDef.withProtocolVersion(AirbyteProtocolVersion.getWithDefault(destDef.getProtocolVersion()).serialize()); + if (destDef != null) { + return destDef.withProtocolVersion(AirbyteProtocolVersion.getWithDefault(destDef.getProtocolVersion()).serialize()); + } + return null; } public StandardDestinationDefinition getDestinationDefinitionFromDestination(final UUID destinationId) {