Supercharge your AI agents with data from the web and beyond. Building the library for superintelligence. 🔥
TypeScript aiai-agentsai-crawlerai-scrapingai-searchcrawlerdata-extractionhtml-to-markdownllmmarkdownscraperscrapingweb-crawlerweb-dataweb-data-extractionweb-scraperweb-scrapingweb-searchwebscraping
address review round 8: skip on shared-quota 429s, unpin upstream miss shape, refresh stale comment
Karan Lokchandanic76f4fd20044
diff --git a/apps/api/src/__tests__/snips/v2/research.test.ts b/apps/api/src/__tests__/snips/v2/research.test.tsindex 9e62753c0..fbcd5fdea 100644--- a/apps/api/src/__tests__/snips/v2/research.test.ts+++ b/apps/api/src/__tests__/snips/v2/research.test.ts@@ -359,12 +359,13 @@ describeIf(HAS_RESEARCH)("Research API", () => {// firecrawl-db migration) and no credit-budget draw-down.itIf(config.USE_DB_AUTHENTICATION === true)("a zero-credit paper search writes no usage row and charges nothing",- async () => {+ async ctx => {const forwardedIp = testNetIp(0);const afterId = await maxKeylessUsageRowId();- // Delta-isolated like the row check: the keyless_credits key on this- // fixed IP lives for a day, so a leftover increment from an earlier- // run must not read as a stray charge now.+ // Delta-isolated like the row check: even though the forwarded IP+ // is unique per run, the credits key lives for a day and octet reuse+ // across runs is possible (1/250), so never compare against absolute+ // zero.const creditsBefore = KEYLESS_PROXY_SECRET? Number((await redisRateLimitClient.get(@@ -382,6 +383,14 @@ describeIf(HAS_RESEARCH)("Research API", () => {),);+ // Without the proxy secret this request drew from the shared+ // loopback quota, which keyless.test.ts legitimately exhausts to the+ // daily cap. A 429 there is environmental, not a regression - skip+ // rather than assert on a bucket this test cannot isolate.+ if (!KEYLESS_PROXY_SECRET && res.statusCode === 429) {+ ctx.skip();+ return;+ }expect(res.statusCode).toBe(200);expect(res.body.success).toBe(true);// The charge path is fire-and-forget, so poll for the *wrong* outcome@@ -421,7 +430,7 @@ describeIf(HAS_RESEARCH)("Research API", () => {// are 0 on every non-2xx path) and stay equally free of DB writes.itIf(config.USE_DB_AUTHENTICATION === true)("a keyless paper lookup miss also writes no usage row",- async () => {+ async ctx => {const forwardedIp = testNetIp(1);const afterId = await maxKeylessUsageRowId();@@ -434,8 +443,15 @@ describeIf(HAS_RESEARCH)("Research API", () => {),);+ if (!KEYLESS_PROXY_SECRET && res.statusCode === 429) {+ ctx.skip();+ return;+ }+ // The upstream shape for a nonexistent ID is not pinned here (mostly+ // a 4xx miss, but a 200-with-empty or redirect is possible): the+ // contract under test is only that keyless auth admitted the request+ // and that NO usage row lands regardless of outcome shape.expect(res.statusCode).not.toBe(401);- expect(res.statusCode).toBeGreaterThanOrEqual(400);// Same polled absence check as the success path: a late write must// fail the test, not slip past a fixed sleep.const strayRow = await waitForSingleRow(