From 1e4f639c47676c5b254c08e710a9f01fd812e54a Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 11 Feb 2026 06:06:28 +0000 Subject: [PATCH 1/6] Initial plan From 5f2d33645194eb4db79b5a1ad21008809a6d67ee Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 11 Feb 2026 06:11:55 +0000 Subject: [PATCH 2/6] Handle missing Algolia facets in fetcher Co-authored-by: AnandChowdhary <2841780+AnandChowdhary@users.noreply.github.com> --- fetcher.ts | 53 +++++++++++++++++++++++++++++++++++++++-------------- 1 file changed, 39 insertions(+), 14 deletions(-) diff --git a/fetcher.ts b/fetcher.ts index 36cc486f8..3647c863a 100644 --- a/fetcher.ts +++ b/fetcher.ts @@ -35,6 +35,11 @@ interface LaunchedCompany { question_answers: boolean; } +const loadExistingCompanies = async (): Promise => { + const data = await Deno.readTextFile("companies/all.json"); + return JSON.parse(data) as LaunchedCompany[]; +}; + const fetchAllCompanies = async (): Promise => { const baseUrl = "https://45bwzj1sgc-dsn.algolia.net/1/indexes/*/queries"; const params = new URLSearchParams({ @@ -46,25 +51,45 @@ const fetchAllCompanies = async (): Promise => { }); console.log("Fetching facets"); - const res = await fetch(`${baseUrl}?${params}`, { - method: "POST", - body: JSON.stringify({ - requests: [ - { - indexName, - params: `facets=%5B%22app_answers%22%2C%22app_video_public%22%2C%22batch%22%2C%22demo_day_video_public%22%2C%22highlight_black%22%2C%22highlight_latinx%22%2C%22highlight_women%22%2C%22industries%22%2C%22isHiring%22%2C%22nonprofit%22%2C%22question_answers%22%2C%22regions%22%2C%22subindustry%22%2C%22tags%22%2C%22top_company%22%5D&hitsPerPage=1000&maxValuesPerFacet=1000&query=&tagFilters=`, - }, - ], - }), - }); + let res: Response; + try { + res = await fetch(`${baseUrl}?${params}`, { + method: "POST", + body: JSON.stringify({ + requests: [ + { + indexName, + params: `facets=%5B%22app_answers%22%2C%22app_video_public%22%2C%22batch%22%2C%22demo_day_video_public%22%2C%22highlight_black%22%2C%22highlight_latinx%22%2C%22highlight_women%22%2C%22industries%22%2C%22isHiring%22%2C%22nonprofit%22%2C%22question_answers%22%2C%22regions%22%2C%22subindustry%22%2C%22tags%22%2C%22top_company%22%5D&hitsPerPage=1000&maxValuesPerFacet=1000&query=&tagFilters=`, + }, + ], + }), + }); + } catch (error) { + console.warn( + `Failed to fetch facets. Using existing data. Error: ${String(error)}` + ); + return loadExistingCompanies(); + } + + if (!res.ok) { + const errorText = await res.text(); + console.warn( + `Failed to fetch facets (${res.status} ${res.statusText}). Using existing data. Response: ${errorText}` + ); + return loadExistingCompanies(); + } const json = (await res.json()) as { - results: { + results?: { hits: LaunchedCompany[]; - facets: { batch: Record }; + facets?: { batch?: Record }; }[]; }; - const batches = json.results[0].facets.batch; + const batches = json.results?.[0]?.facets?.batch; + if (!batches) { + console.warn("No batch facets returned. Using existing data."); + return loadExistingCompanies(); + } let allCompanies: LaunchedCompany[] = []; for (const [batch, count] of Object.entries(batches)) { From eff11d47506d21c9450c9b698cce9978e95f82e8 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 11 Feb 2026 06:12:37 +0000 Subject: [PATCH 3/6] Improve fetcher fallback diagnostics Co-authored-by: AnandChowdhary <2841780+AnandChowdhary@users.noreply.github.com> --- fetcher.ts | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/fetcher.ts b/fetcher.ts index 3647c863a..9d68adec6 100644 --- a/fetcher.ts +++ b/fetcher.ts @@ -36,8 +36,14 @@ interface LaunchedCompany { } const loadExistingCompanies = async (): Promise => { - const data = await Deno.readTextFile("companies/all.json"); - return JSON.parse(data) as LaunchedCompany[]; + try { + const data = await Deno.readTextFile("companies/all.json"); + return JSON.parse(data) as LaunchedCompany[]; + } catch (error) { + const message = error instanceof Error ? error.message : String(error); + console.error(`Failed to load existing companies data: ${message}`); + throw error; + } }; const fetchAllCompanies = async (): Promise => { @@ -65,8 +71,9 @@ const fetchAllCompanies = async (): Promise => { }), }); } catch (error) { + const message = error instanceof Error ? error.message : String(error); console.warn( - `Failed to fetch facets. Using existing data. Error: ${String(error)}` + `Failed to fetch facets. Using existing data. Error: ${message}` ); return loadExistingCompanies(); } From 21b1bcf3f9010f329dd7822047398db9aab67640 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 11 Feb 2026 06:13:26 +0000 Subject: [PATCH 4/6] Improve cached data fallback messaging Co-authored-by: AnandChowdhary <2841780+AnandChowdhary@users.noreply.github.com> --- fetcher.ts | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/fetcher.ts b/fetcher.ts index 9d68adec6..9c3b72257 100644 --- a/fetcher.ts +++ b/fetcher.ts @@ -35,14 +35,20 @@ interface LaunchedCompany { question_answers: boolean; } -const loadExistingCompanies = async (): Promise => { +const loadExistingCompanies = async ( + reason: string +): Promise => { try { const data = await Deno.readTextFile("companies/all.json"); return JSON.parse(data) as LaunchedCompany[]; } catch (error) { const message = error instanceof Error ? error.message : String(error); - console.error(`Failed to load existing companies data: ${message}`); - throw error; + const prefix = + error instanceof Deno.errors.NotFound + ? `No cached data available and ${reason}.` + : `Failed to load cached data after ${reason}.`; + console.error(`${prefix} ${message}`); + throw new Error(`${prefix} ${message}`); } }; @@ -75,7 +81,7 @@ const fetchAllCompanies = async (): Promise => { console.warn( `Failed to fetch facets. Using existing data. Error: ${message}` ); - return loadExistingCompanies(); + return loadExistingCompanies("facet fetch failed"); } if (!res.ok) { @@ -83,7 +89,9 @@ const fetchAllCompanies = async (): Promise => { console.warn( `Failed to fetch facets (${res.status} ${res.statusText}). Using existing data. Response: ${errorText}` ); - return loadExistingCompanies(); + return loadExistingCompanies( + `facet request returned ${res.status} ${res.statusText}` + ); } const json = (await res.json()) as { @@ -95,7 +103,7 @@ const fetchAllCompanies = async (): Promise => { const batches = json.results?.[0]?.facets?.batch; if (!batches) { console.warn("No batch facets returned. Using existing data."); - return loadExistingCompanies(); + return loadExistingCompanies("response missing batch facets"); } let allCompanies: LaunchedCompany[] = []; From c09fca83f217f5b1c05ef38deb36827473a16f40 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 11 Feb 2026 06:14:12 +0000 Subject: [PATCH 5/6] Clarify cached data load failures Co-authored-by: AnandChowdhary <2841780+AnandChowdhary@users.noreply.github.com> --- fetcher.ts | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/fetcher.ts b/fetcher.ts index 9c3b72257..8dde2f866 100644 --- a/fetcher.ts +++ b/fetcher.ts @@ -47,7 +47,6 @@ const loadExistingCompanies = async ( error instanceof Deno.errors.NotFound ? `No cached data available and ${reason}.` : `Failed to load cached data after ${reason}.`; - console.error(`${prefix} ${message}`); throw new Error(`${prefix} ${message}`); } }; @@ -95,12 +94,17 @@ const fetchAllCompanies = async (): Promise => { } const json = (await res.json()) as { - results?: { + results: { hits: LaunchedCompany[]; facets?: { batch?: Record }; }[]; }; - const batches = json.results?.[0]?.facets?.batch; + if (!json.results?.length) { + console.warn("No results returned. Using existing data."); + return loadExistingCompanies("response missing results"); + } + + const batches = json.results[0].facets?.batch; if (!batches) { console.warn("No batch facets returned. Using existing data."); return loadExistingCompanies("response missing batch facets"); From e62fd027eaf27c916407b18f5a49f089cd4c0122 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 11 Feb 2026 06:14:53 +0000 Subject: [PATCH 6/6] Refine cached data fallback naming Co-authored-by: AnandChowdhary <2841780+AnandChowdhary@users.noreply.github.com> --- fetcher.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/fetcher.ts b/fetcher.ts index 8dde2f866..2d8535873 100644 --- a/fetcher.ts +++ b/fetcher.ts @@ -36,7 +36,7 @@ interface LaunchedCompany { } const loadExistingCompanies = async ( - reason: string + failureReason: string ): Promise => { try { const data = await Deno.readTextFile("companies/all.json"); @@ -45,8 +45,8 @@ const loadExistingCompanies = async ( const message = error instanceof Error ? error.message : String(error); const prefix = error instanceof Deno.errors.NotFound - ? `No cached data available and ${reason}.` - : `Failed to load cached data after ${reason}.`; + ? `No cached data available and ${failureReason}.` + : `Failed to load cached data after ${failureReason}.`; throw new Error(`${prefix} ${message}`); } }; @@ -96,7 +96,7 @@ const fetchAllCompanies = async (): Promise => { const json = (await res.json()) as { results: { hits: LaunchedCompany[]; - facets?: { batch?: Record }; + facets: { batch: Record }; }[]; }; if (!json.results?.length) {