Skip to content

Commit

Permalink
Handle null reset source config (#14202)
Browse files Browse the repository at this point in the history
* handle null reset source config

* format
  • Loading branch information
lmossman authored Jun 27, 2022
1 parent 8ebd5a0 commit 11d4cc7
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
import io.airbyte.config.Configs.WorkerEnvironment;
import io.airbyte.config.JobConfig.ConfigType;
import io.airbyte.config.JobOutput;
import io.airbyte.config.ResetSourceConfiguration;
import io.airbyte.config.StandardSyncOutput;
import io.airbyte.config.StandardSyncSummary;
import io.airbyte.config.StreamSyncStats;
Expand Down Expand Up @@ -101,6 +102,10 @@ public static JobWithAttemptsRead getJobWithAttemptsRead(final Job job) {
*/
private static Optional<ResetConfig> extractResetConfigIfReset(final Job job) {
if (job.getConfigType() == ConfigType.RESET_CONNECTION) {
final ResetSourceConfiguration resetSourceConfiguration = job.getConfig().getResetConnection().getResetSourceConfiguration();
if (resetSourceConfiguration == null) {
return Optional.empty();
}
return Optional.ofNullable(
new ResetConfig().streamsToReset(job.getConfig().getResetConnection().getResetSourceConfiguration().getStreamsToReset()
.stream()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
package io.airbyte.server.converters;

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNull;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
Expand Down Expand Up @@ -257,4 +258,23 @@ void testResetJobIncludesResetConfig() {
assertEquals(expectedResetConfig, jobConverter.getJobInfoRead(resetJob).getJob().getResetConfig());
}

@Test
void testResetJobExcludesConfigIfNull() {
final JobConfig resetConfig = new JobConfig()
.withConfigType(ConfigType.RESET_CONNECTION)
.withResetConnection(new JobResetConnectionConfig().withResetSourceConfiguration(null));
final Job resetJob = new Job(
JOB_ID,
ConfigType.RESET_CONNECTION,
JOB_CONFIG_ID,
resetConfig,
Collections.emptyList(),
JobStatus.SUCCEEDED,
CREATED_AT,
CREATED_AT,
CREATED_AT);

assertNull(jobConverter.getJobInfoRead(resetJob).getJob().getResetConfig());
}

}

0 comments on commit 11d4cc7

Please sign in to comment.