Skip to content

Commit

Permalink
[connectors] - fix: handle missing webcrawler config for connectors (#…
Browse files Browse the repository at this point in the history
…5245)

- Return an error if the `WebCrawlerConfiguration` is not found for a given connector ID
 - Change the logic to determine the `webCrawlerQueueName` based on the existence of `lastCrawledAt` in the configuration

Co-authored-by: Jules <jules@MacBook-Pro.local>
  • Loading branch information
JulesBelveze and Jules authored May 23, 2024
1 parent fed522b commit 6f1d692
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions connectors/src/connectors/webcrawler/temporal/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,13 @@ export async function launchCrawlWebsiteWorkflow(
const webcrawlerConfig =
await WebCrawlerConfigurationResource.fetchByConnectorId(connector.id);

const webCrawlerQueueName = webcrawlerConfig?.lastCrawledAt
? WebCrawlerQueueNames.NEW_WEBSITE
: WebCrawlerQueueNames.UPDATE_WEBSITE;
if (!webcrawlerConfig) {
return new Err(new Error(`CrawlerConfig not found for ${connector.id}`));
}

const webCrawlerQueueName = webcrawlerConfig.lastCrawledAt
? WebCrawlerQueueNames.UPDATE_WEBSITE
: WebCrawlerQueueNames.NEW_WEBSITE;

const client = await getTemporalClient();
const workflowId = crawlWebsiteWorkflowId(connectorId);
Expand Down

0 comments on commit 6f1d692

Please sign in to comment.