Skip to content

tolerate missing source catalog used to make the configured catalog #20928

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
Dec 29, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -348,17 +348,17 @@ public WebBackendConnectionRead webBackendGetConnection(final WebBackendConnecti
/*
* constructs a full picture of all existing configured + all new / updated streams in the newest
* catalog.
*/
syncCatalog = updateSchemaWithRefreshedDiscoveredCatalog(configuredCatalog, catalogUsedToMakeConfiguredCatalog.get(),
refreshedCatalog.get().getCatalog());
/*
*
* Diffing the catalog used to make the configured catalog gives us the clearest diff between the
* schema when the configured catalog was made and now. In the case where we do not have the
* original catalog used to make the configured catalog, we make due, but using the configured
* catalog itself. The drawback is that any stream that was not selected in the configured catalog
* but was present at time of configuration will appear in the diff as an added stream which is
* confusing. We need to figure out why source_catalog_id is not always populated in the db.
*/
syncCatalog = updateSchemaWithRefreshedDiscoveredCatalog(configuredCatalog, catalogUsedToMakeConfiguredCatalog.orElse(configuredCatalog),
Copy link
Contributor

Choose a reason for hiding this comment

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

in the update endpoint, we just check to make sure that catalogUsedToMakeConfiguredCatalog is present before calling this. Maybe we should do the same thing here?

    final Optional<AirbyteCatalog> catalogUsedToMakeConfiguredCatalog = connectionsHandler
        .getConnectionAirbyteCatalog(connectionId);
    if (catalogUsedToMakeConfiguredCatalog.isPresent()) {
      // Update the Catalog returned to include all streams, including disabled ones
      final AirbyteCatalog syncCatalog =
          updateSchemaWithRefreshedDiscoveredCatalog(updatedConnectionRead.getSyncCatalog(), catalogUsedToMakeConfiguredCatalog.get(),
              catalogUsedToMakeConfiguredCatalog.get());
      updatedConnectionRead.setSyncCatalog(syncCatalog);
    }

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 behaviour here is that if the catalogUsedToMakeConfiguredCatalog is missing, then we'll show any previously de-selected fields as "newly added" rather than "already existed but de-selected". This is indeed not ideal, but not returning a diff is also a problem since the frontend needs the diff to decide what to display to the user.

The previous decision was that if we don't have the catalogUsedToMakeConfiguredCatalog then we can wrongly display streams as newly-added, so this approach is consistent with that.

I don't actually understand the behaviour in the update endpoint - it may be that the frontend isn't actually using the value returned by the update endpoint? Otherwise, I can't figure out how it's okay to just sometimes not populate the sync catalog field?

Copy link
Contributor

Choose a reason for hiding this comment

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

ah I see what you're saying here. I'd have to look at the update endpoint more closely to figure out the logic there, I'm not 100% sure why it would be ok to not populate sync catalog. but I think for this endpoint this is fine

refreshedCatalog.get().getCatalog());

diff = refreshedCatalog.get().getCatalogDiff();
connection.setBreakingChange(refreshedCatalog.get().getBreakingChange());
connection.setStatus(refreshedCatalog.get().getConnectionStatus());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -456,6 +456,24 @@ void testWebBackendGetConnectionWithDiscoveryAndNewSchemaBreakingChange() throws
assertEquals(expectedWithNewSchemaAndBreakingChange, result);
}

@Test
void testWebBackendGetConnectionWithDiscoveryMissingCatalogUsedToMakeConfiguredCatalog()
throws IOException, ConfigNotFoundException, JsonValidationException {
final UUID newCatalogId = UUID.randomUUID();
when(configRepository.getMostRecentActorCatalogFetchEventForSource(any()))
.thenReturn(Optional.of(new ActorCatalogFetchEvent().withActorCatalogId(newCatalogId)));
when(configRepository.getActorCatalogById(any())).thenReturn(new ActorCatalog().withId(UUID.randomUUID()));
final SourceDiscoverSchemaRead schemaRead =
new SourceDiscoverSchemaRead().catalogDiff(expectedWithNewSchema.getCatalogDiff()).catalog(expectedWithNewSchema.getSyncCatalog())
.breakingChange(false).connectionStatus(ConnectionStatus.ACTIVE);
when(schedulerHandler.discoverSchemaForSourceFromSourceId(any())).thenReturn(schemaRead);
when(connectionsHandler.getConnectionAirbyteCatalog(connectionRead.getConnectionId())).thenReturn(Optional.empty());

final WebBackendConnectionRead result = testWebBackendGetConnection(true, connectionRead,
operationReadList);
assertEquals(expectedWithNewSchema, result);
}

@Test
void testWebBackendGetConnectionWithDiscoveryAndFieldSelectionAddField() throws ConfigNotFoundException,
IOException, JsonValidationException {
Expand Down