From e98f858eb6ad27218b11f95aaaa8b3e21e90f57c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gerg=C5=91=20M=C3=B3ricz?= Date: Thu, 26 Sep 2024 22:28:14 +0200 Subject: [PATCH] fix(api): playground scrape errors --- apps/api/src/controllers/v0/scrape.ts | 2 +- apps/api/src/controllers/v0/search.ts | 2 +- apps/api/src/controllers/v1/map.ts | 2 +- apps/api/src/controllers/v1/scrape.ts | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/apps/api/src/controllers/v0/scrape.ts b/apps/api/src/controllers/v0/scrape.ts index db304fed..2a0fcc13 100644 --- a/apps/api/src/controllers/v0/scrape.ts +++ b/apps/api/src/controllers/v0/scrape.ts @@ -244,7 +244,7 @@ export async function scrapeController(req: Request, res: Response) { } if (creditsToBeBilled > 0) { // billing for doc done on queue end, bill only for llm extraction - billTeam(team_id, chunk.sub_id, creditsToBeBilled).catch(error => { + billTeam(team_id, chunk?.sub_id, creditsToBeBilled).catch(error => { Logger.error(`Failed to bill team ${team_id} for ${creditsToBeBilled} credits: ${error}`); // Optionally, you could notify an admin or add to a retry queue here }); diff --git a/apps/api/src/controllers/v0/search.ts b/apps/api/src/controllers/v0/search.ts index 2d8c69de..64870605 100644 --- a/apps/api/src/controllers/v0/search.ts +++ b/apps/api/src/controllers/v0/search.ts @@ -170,7 +170,7 @@ export async function searchController(req: Request, res: Response) { jobId, req, team_id, - chunk.sub_id, + chunk?.sub_id, crawlerOptions, pageOptions, searchOptions, diff --git a/apps/api/src/controllers/v1/map.ts b/apps/api/src/controllers/v1/map.ts index aca03ced..cc5f6aa3 100644 --- a/apps/api/src/controllers/v1/map.ts +++ b/apps/api/src/controllers/v1/map.ts @@ -152,7 +152,7 @@ export async function mapController( // remove duplicates that could be due to http/https or www links = removeDuplicateUrls(links); - billTeam(req.auth.team_id, req.acuc.sub_id, 1).catch((error) => { + billTeam(req.auth.team_id, req.acuc?.sub_id, 1).catch((error) => { Logger.error( `Failed to bill team ${req.auth.team_id} for 1 credit: ${error}` ); diff --git a/apps/api/src/controllers/v1/scrape.ts b/apps/api/src/controllers/v1/scrape.ts index 41974917..899ae74a 100644 --- a/apps/api/src/controllers/v1/scrape.ts +++ b/apps/api/src/controllers/v1/scrape.ts @@ -108,7 +108,7 @@ export async function scrapeController( creditsToBeBilled = 5; } - billTeam(req.auth.team_id, req.acuc.sub_id, creditsToBeBilled).catch(error => { + billTeam(req.auth.team_id, req.acuc?.sub_id, creditsToBeBilled).catch(error => { Logger.error(`Failed to bill team ${req.auth.team_id} for ${creditsToBeBilled} credits: ${error}`); // Optionally, you could notify an admin or add to a retry queue here });