From 1fb1de830364b9ab13e771ac442c4ef9df166bee Mon Sep 17 00:00:00 2001 From: Haewon Kam Date: Sat, 4 Apr 2026 01:38:12 +0900 Subject: [PATCH] fix: keep unverified Instagram handles as candidates for collection Instagram HEAD requests often fail (rate limiting, blocking) causing valid handles to be dropped. Now all discovered handles are kept (verified or not) and Apify attempts collection on all of them. Apify's own scraper validates existence more reliably than HEAD requests. Co-Authored-By: Claude Opus 4.6 (1M context) --- supabase/functions/_shared/verifyHandles.ts | 4 ++-- supabase/functions/collect-channel-data/index.ts | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/supabase/functions/_shared/verifyHandles.ts b/supabase/functions/_shared/verifyHandles.ts index 1dd95c2..7812189 100644 --- a/supabase/functions/_shared/verifyHandles.ts +++ b/supabase/functions/_shared/verifyHandles.ts @@ -190,10 +190,10 @@ export async function verifyAllHandles( tiktok: null, }; - // Instagram — verify each candidate + // Instagram — verify each candidate, keep unverified as fallback for (const handle of candidates.instagram.slice(0, 5)) { tasks.push( - verifyInstagram(handle).then(v => { if (v.verified) result.instagram.push(v); }) + verifyInstagram(handle).then(v => { result.instagram.push(v); }) ); } diff --git a/supabase/functions/collect-channel-data/index.ts b/supabase/functions/collect-channel-data/index.ts index e3f2e17..1221432 100644 --- a/supabase/functions/collect-channel-data/index.ts +++ b/supabase/functions/collect-channel-data/index.ts @@ -72,12 +72,12 @@ Deno.serve(async (req) => { const analysisData: Record = {}; const tasks: Promise[] = []; - // ─── 1. Instagram (multi-account) ─── - const igVerified = (verified.instagram || []).filter((v: Record) => v.verified && v.handle); - if (APIFY_TOKEN && igVerified.length > 0) { + // ─── 1. Instagram (multi-account) — try ALL candidates including unverified ─── + const igCandidates = (verified.instagram || []).filter((v: Record) => v.handle); + if (APIFY_TOKEN && igCandidates.length > 0) { tasks.push((async () => { const accounts: Record[] = []; - for (const ig of igVerified) { + for (const ig of igCandidates) { const items = await runApifyActor("apify~instagram-profile-scraper", { usernames: [ig.handle], resultsLimit: 12 }, APIFY_TOKEN); const profile = (items as Record[])[0]; if (profile && !profile.error) {