Skip to content

Supercharge your AI agents with data from the web and beyond. Building the library for superintelligence. 🔥

fix(api): drop noisy INFO log on the developer-category fallback; use vi.hoisted for gate test mocks

Kris Oeib585591ad83f
diff --git a/apps/api/src/controllers/v2/__tests__/developer-beta-gate.test.ts b/apps/api/src/controllers/v2/__tests__/developer-beta-gate.test.ts
index d27263c58..1e98e5e75 100644
--- a/apps/api/src/controllers/v2/__tests__/developer-beta-gate.test.ts
+++ b/apps/api/src/controllers/v2/__tests__/developer-beta-gate.test.ts
@@ -1,19 +1,20 @@
import { vi } from "vitest";
-const mockLogRequest = vi.fn();
-const mockLogSearch = vi.fn();
-const mockLogResearchEndpoint = vi.fn();
+const mocks = vi.hoisted(() => ({
+ logRequest: vi.fn(),
+ logSearch: vi.fn(),
+ logResearchEndpoint: vi.fn(),
+ fetchResearchUpstream: vi.fn(),
+}));
vi.mock("../../../services/logging/log_job", () => ({
- logRequest: (...args: any[]) => mockLogRequest(...args),
- logSearch: (...args: any[]) => mockLogSearch(...args),
- logResearchEndpoint: (...args: any[]) => mockLogResearchEndpoint(...args),
+ logRequest: mocks.logRequest,
+ logSearch: mocks.logSearch,
+ logResearchEndpoint: mocks.logResearchEndpoint,
}));
-const mockFetchResearchUpstream = vi.fn();
-
vi.mock("../../../lib/research-upstream", () => ({
- fetchResearchUpstream: (...args: any[]) => mockFetchResearchUpstream(...args),
+ fetchResearchUpstream: mocks.fetchResearchUpstream,
}));
vi.mock("../../../services/billing/credit_billing", () => ({
@@ -64,8 +65,8 @@ function makeRes() {
beforeEach(() => {
vi.clearAllMocks();
- mockLogRequest.mockResolvedValue(undefined);
- mockLogResearchEndpoint.mockResolvedValue(undefined);
+ mocks.logRequest.mockResolvedValue(undefined);
+ mocks.logResearchEndpoint.mockResolvedValue(undefined);
});
describe.each([
@@ -77,8 +78,8 @@ describe.each([
await developerHandler(options)(makeReq({ developerBeta: false }), res);
expect(res.status).toHaveBeenCalledWith(403);
- expect(mockFetchResearchUpstream).not.toHaveBeenCalled();
- expect(mockLogRequest).not.toHaveBeenCalled();
+ expect(mocks.fetchResearchUpstream).not.toHaveBeenCalled();
+ expect(mocks.logRequest).not.toHaveBeenCalled();
});
it("403s a keyless caller (no acuc at all)", async () => {
@@ -86,11 +87,11 @@ describe.each([
await developerHandler(options)(makeReq(null), res);
expect(res.status).toHaveBeenCalledWith(403);
- expect(mockFetchResearchUpstream).not.toHaveBeenCalled();
+ expect(mocks.fetchResearchUpstream).not.toHaveBeenCalled();
});
it("does not 403 a team with developerBeta", async () => {
- mockFetchResearchUpstream.mockResolvedValue(null); // 404 path, past the gate
+ mocks.fetchResearchUpstream.mockResolvedValue(null); // 404 path, past the gate
const res = makeRes();
await developerHandler(options)(makeReq({ developerBeta: true }), res);
diff --git a/apps/api/src/controllers/v2/search.ts b/apps/api/src/controllers/v2/search.ts
index 39b53f093..38df521f6 100644
--- a/apps/api/src/controllers/v2/search.ts
+++ b/apps/api/src/controllers/v2/search.ts
@@ -84,9 +84,8 @@ export async function searchController(
// key lacks access to a category that is about to be removed anyway.
if (wantsDeveloperCategory(req.body.categories as CategoryOption[])) {
if (req.acuc?.flags?.developerBeta !== true) {
- logger.info(
- "developer category requested without developerBeta flag; dropping",
- );
+ // Expected, high-volume path (keyless + unentitled teams) — left
+ // unlogged on purpose to avoid log spam. See PR discussion.
// filter() widens the union that categories is declared as (either an
// all-string or an all-object array), so the result is cast back to
// assign it.