Skip to content

Commit

Permalink
Ensure we have protocol version on actor def reads (airbytehq#18206)
Browse files Browse the repository at this point in the history
* Ensure we have protocol version on actor def reads

* Fix null ref
  • Loading branch information
gosusnp authored and jhammarstedt committed Oct 31, 2022
1 parent 76cf460 commit 99adc4b
Showing 1 changed file with 16 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -190,10 +190,16 @@ 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.
if (sourceDef != null) {
return sourceDef.withProtocolVersion(AirbyteProtocolVersion.getWithDefault(sourceDef.getProtocolVersion()).serialize());
}
return null;
}

public StandardSourceDefinition getSourceDefinitionFromSource(final UUID sourceId) {
Expand Down Expand Up @@ -302,8 +308,15 @@ 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.
if (destDef != null) {
return destDef.withProtocolVersion(AirbyteProtocolVersion.getWithDefault(destDef.getProtocolVersion()).serialize());
}
return null;
}

public StandardDestinationDefinition getDestinationDefinitionFromDestination(final UUID destinationId) {
Expand Down

0 comments on commit 99adc4b

Please sign in to comment.