Fix: FCC errors now fall through to local DB fallback

Was returning 502 early instead of throwing to trigger the catch block
where the local fcc_499_filers fallback lives.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
justin 2026-05-22 00:42:43 -05:00
parent bbfa6393fa
commit b91e76e44c

View file

@ -1280,16 +1280,14 @@ router.get("/api/v1/fcc/cores-search", async (req, res) => {
});
if (!resp.ok) {
res.status(502).json({ error: `The FCC search system is temporarily unavailable (HTTP ${resp.status}). Try searching by FRN instead, or try again in a few minutes.` });
return;
throw new Error(`FCC returned HTTP ${resp.status}`);
}
const html = await resp.text();
// FCC sometimes returns 200 but with a maintenance/error page
if (html.includes("Service Unavailable") || (html.includes("503") && !html.includes("499results"))) {
res.status(502).json({ error: "The FCC search system is temporarily unavailable. Try searching by FRN instead, or try again in a few minutes." });
return;
if (html.includes("Service Unavailable") || html.includes("FCC Website Error") || (html.includes("503") && !html.includes("499results"))) {
throw new Error("FCC search returned maintenance page");
}
// Parse the results table rows: <tr><th scope="row">834314</th> ... <td><A HREF="499detail.cfm?FilerNum=834314">Carrier One Inc.</a></td><td>DBA</td></tr>