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
fix(api): name the option that keeps a provider out of a blocklisted URL (#5002)
Gergő Móricz6c673c968c6b
diff --git a/apps/api/src/__tests__/snips/v2/batch-scrape-exchange.test.ts b/apps/api/src/__tests__/snips/v2/batch-scrape-exchange.test.tsindex 4906eb49a..f734b141b 100644--- a/apps/api/src/__tests__/snips/v2/batch-scrape-exchange.test.ts+++ b/apps/api/src/__tests__/snips/v2/batch-scrape-exchange.test.ts@@ -1,7 +1,8 @@/*** v2 batch scrape admits blocklisted URLs the Exchange can serve, the same* way single scrape does, and refuses the rest: with the terms error when- * unaccepted terms are what keeps a URL out, else as an unsupported site.+ * unaccepted terms are what keeps a URL out, with the unsupported-option+ * error when a request option does, else as an unsupported site.*/const mocks = vi.hoisted(() => ({@@ -64,6 +65,7 @@ import {clearExchangeProvidersForTest,setExchangeProvidersForTest,ThirdPartyDataTermsRequiredError,+ ThirdPartyDataUnsupportedOptionError,} from "../../../lib/exchange";import { UnsupportedSiteError } from "../../../lib/error";import { UNSUPPORTED_SITE_MESSAGE } from "../../../lib/strings";@@ -208,6 +210,32 @@ describe("v2 batch scrape of blocklisted URLs", () => {]);});+ it("names the option that keeps the provider out of a blocked URL", async () => {+ const result = await batchScrape(+ {+ urls: [OPEN_URL, BLOCKED_URL],+ ignoreInvalidURLs: false,+ redactPII: true,+ },+ ACCEPTED_FLAGS,+ );++ expect(result).toEqual({+ status: 400,+ body: new ThirdPartyDataUnsupportedOptionError(+ "`redactPII`",+ ).response(),+ });+ expect(result.body.code).toBe("THIRD_PARTY_DATA_UNSUPPORTED_OPTION");+ expect(enqueuedJobs()).toEqual([]);+ expect(rejectedEvents()).toEqual([+ expect.objectContaining({+ url: BLOCKED_URL,+ error: expect.any(ThirdPartyDataUnsupportedOptionError),+ }),+ ]);+ });+it("rejects a blocked URL the Exchange cannot serve as an unsupported site", async () => {const result = await batchScrape({ urls: [OPEN_URL, UNSERVED_URL], ignoreInvalidURLs: false },diff --git a/apps/api/src/__tests__/snips/v2/exchange-routing.test.ts b/apps/api/src/__tests__/snips/v2/exchange-routing.test.tsindex f64f104c0..2dd6956f5 100644--- a/apps/api/src/__tests__/snips/v2/exchange-routing.test.ts+++ b/apps/api/src/__tests__/snips/v2/exchange-routing.test.ts@@ -178,12 +178,9 @@ describe("Exchange routing", () => {});it("blocks a blocked URL the Exchange cannot serve", async () => {+ exchange.setExchangeProvidersForTest([]);const result = await runGate(- {- url: BLOCKED_URL,- formats: ["markdown"],- actions: [{ type: "wait", milliseconds: 1000 }],- },+ { url: BLOCKED_URL, formats: ["markdown"] },ACCEPTED_FLAGS,);@@ -193,6 +190,52 @@ describe("Exchange routing", () => {});expect((result as any).body.code).toBeUndefined();});++ it.each([+ {+ options: { formats: ["markdown", "screenshot"] },+ option: "the `screenshot` format",+ },+ {+ options: { actions: [{ type: "wait", milliseconds: 1000 }] },+ option: "`actions`",+ },+ { options: { zeroDataRetention: true }, option: "zero data retention" },+ { options: { redactPII: true }, option: "`redactPII`" },+ ])(+ "names $option when it keeps the provider out of a blocked URL",+ async ({ options, option }) => {+ const result = await runGate(+ { url: BLOCKED_URL, formats: ["markdown"], ...options },+ ACCEPTED_FLAGS,+ );++ expect(result).toEqual({+ status: 400,+ body: new exchange.ThirdPartyDataUnsupportedOptionError(+ option,+ ).response(),+ });+ expect((result as any).body.code).toBe(+ "THIRD_PARTY_DATA_UNSUPPORTED_OPTION",+ );+ expect((result as any).body.error).toContain(option);+ expect((result as any).body.error).not.toContain("contact-sales");+ },+ );++ it("lets a blocked URL through with formats the provider serves and redactPII off", async () => {+ await expect(+ runGate(+ {+ url: BLOCKED_URL,+ formats: ["markdown", { type: "json", prompt: "Extract the name" }],+ redactPII: false,+ },+ ACCEPTED_FLAGS,+ ),+ ).resolves.toEqual({ next: true });+ });});describe("buildFallbackList", () => {@@ -226,10 +269,27 @@ describe("Exchange routing", () => {});it("fails closed for a blocked URL the Exchange cannot serve", async () => {+ exchange.setExchangeProvidersForTest([]);++ await expect(+ buildFallbackList(buildStubMeta(BLOCKED_URL, ACCEPTED_FLAGS)),+ ).resolves.toEqual([]);+ });++ it("names the option that keeps the provider out of a blocked URL", async () => {const meta = buildStubMeta(BLOCKED_URL, ACCEPTED_FLAGS);meta.options.actions = [{ type: "wait", milliseconds: 1000 }];- await expect(buildFallbackList(meta)).resolves.toEqual([]);+ const error = await buildFallbackList(meta).catch(e => e);++ expect(error).toBeInstanceOf(+ exchange.ThirdPartyDataUnsupportedOptionError,+ );+ expect(error.response()).toEqual(+ new exchange.ThirdPartyDataUnsupportedOptionError(+ "`actions`",+ ).response(),+ );});});diff --git a/apps/api/src/controllers/v1/scrape.ts b/apps/api/src/controllers/v1/scrape.tsindex fe9805c34..8ffec9240 100644--- a/apps/api/src/controllers/v1/scrape.ts+++ b/apps/api/src/controllers/v1/scrape.ts@@ -431,7 +431,10 @@ async function scrapeControllerInner(});}- if (e.code === "THIRD_PARTY_DATA_UNSUPPORTED_URL") {+ if (+ e.code === "THIRD_PARTY_DATA_UNSUPPORTED_URL" ||+ e.code === "THIRD_PARTY_DATA_UNSUPPORTED_OPTION"+ ) {return res.status(400).json({success: false,code: e.code,diff --git a/apps/api/src/controllers/v2/batch-scrape.ts b/apps/api/src/controllers/v2/batch-scrape.tsindex d1cbc5069..d6d4bfc55 100644--- a/apps/api/src/controllers/v2/batch-scrape.ts+++ b/apps/api/src/controllers/v2/batch-scrape.ts@@ -50,7 +50,10 @@ import { calculateThreatScanCredits } from "../../lib/scrape-billing";import { billTeam } from "../../services/billing/credit_billing";import { emitRejectedScrapeActivityEvents } from "../../lib/siem-logging";import { UnsupportedSiteError } from "../../lib/error";-import { ThirdPartyDataTermsRequiredError } from "../../lib/exchange";+import {+ ThirdPartyDataTermsRequiredError,+ ThirdPartyDataUnsupportedOptionError,+} from "../../lib/exchange";import { getExchangeAccessForRequestBody } from "../../lib/exchange-request";import {AGENT_REQUEST_CREDITS_SHARDS,@@ -181,9 +184,14 @@ export async function batchScrapeController(if (exchangeAccess.allowed) {return null;}- return exchangeAccess.termsRequired- ? new ThirdPartyDataTermsRequiredError(exchangeAccess.terms)- : new UnsupportedSiteError();+ if (exchangeAccess.termsRequired) {+ return new ThirdPartyDataTermsRequiredError(exchangeAccess.terms);+ }+ return exchangeAccess.unsupportedOption === undefined+ ? new UnsupportedSiteError()+ : new ThirdPartyDataUnsupportedOptionError(+ exchangeAccess.unsupportedOption,+ );};let urls: string[] = req.body.urls;@@ -191,7 +199,10 @@ export async function batchScrapeController(let invalidURLs: string[] | undefined = undefined;const refusedURLs: {url: string;- error: UnsupportedSiteError | ThirdPartyDataTermsRequiredError;+ error:+ | UnsupportedSiteError+ | ThirdPartyDataTermsRequiredError+ | ThirdPartyDataUnsupportedOptionError;}[] = [];if (req.body.ignoreInvalidURLs) {@@ -241,16 +252,25 @@ export async function batchScrapeController();if (!req.body.ignoreInvalidURLs && refusedURLs.length > 0) {- // Unaccepted terms are the one refusal the caller can fix, so they win.- const termsRequired = refusedURLs- .map(x => x.error)- .find(error => error instanceof ThirdPartyDataTermsRequiredError);- return res.status(403).json(- termsRequired?.response() ?? {- success: false,- error: UNSUPPORTED_SITE_MESSAGE,- },+ // Unaccepted terms and an unsupported option are the refusals the caller+ // can fix, so they win over an unsupported site.+ const errors = refusedURLs.map(x => x.error);+ const termsRequired = errors.find(+ error => error instanceof ThirdPartyDataTermsRequiredError,+ );+ if (termsRequired) {+ return res.status(403).json(termsRequired.response());+ }+ const unsupportedOption = errors.find(+ error => error instanceof ThirdPartyDataUnsupportedOptionError,);+ if (unsupportedOption) {+ return res.status(400).json(unsupportedOption.response());+ }+ return res.status(403).json({+ success: false,+ error: UNSUPPORTED_SITE_MESSAGE,+ });}// Threat protection: reject/report blocked URLs at enqueue time so theydiff --git a/apps/api/src/controllers/v2/scrape.ts b/apps/api/src/controllers/v2/scrape.tsindex 7b8dddd32..59600a8a2 100644--- a/apps/api/src/controllers/v2/scrape.ts+++ b/apps/api/src/controllers/v2/scrape.ts@@ -625,7 +625,10 @@ export async function scrapeController(});}- if (e.code === "THIRD_PARTY_DATA_UNSUPPORTED_URL") {+ if (+ e.code === "THIRD_PARTY_DATA_UNSUPPORTED_URL" ||+ e.code === "THIRD_PARTY_DATA_UNSUPPORTED_OPTION"+ ) {setSpanAttributes(span, {"scrape.status_code": 400,});diff --git a/apps/api/src/lib/error-serde.ts b/apps/api/src/lib/error-serde.tsindex 6d7d01ebf..1d679061c 100644--- a/apps/api/src/lib/error-serde.ts+++ b/apps/api/src/lib/error-serde.ts@@ -45,13 +45,17 @@ import {ExchangeRefusedError,} from "../scraper/scrapeURL/error";import { UnsafeDomainBlockedError } from "./threat-protection/error";-import { ThirdPartyDataTermsRequiredError } from "./exchange";+import {+ ThirdPartyDataTermsRequiredError,+ ThirdPartyDataUnsupportedOptionError,+} from "./exchange";// TODO: figure out correct typing for thisconst errorMap: Record<ErrorCodes, any> = {THIRD_PARTY_DATA_TERMS_REQUIRED: ThirdPartyDataTermsRequiredError,THIRD_PARTY_DATA_NOT_FOUND: ExchangeRefusedError,THIRD_PARTY_DATA_UNSUPPORTED_URL: ExchangeRefusedError,+ THIRD_PARTY_DATA_UNSUPPORTED_OPTION: ThirdPartyDataUnsupportedOptionError,THIRD_PARTY_DATA_NOT_ENABLED: ExchangeRefusedError,THIRD_PARTY_DATA_ENRICHMENT_NOT_ENABLED: ExchangeRefusedError,SAFE_MODE_BLOCKED: null,diff --git a/apps/api/src/lib/error.ts b/apps/api/src/lib/error.tsindex 4b4b93e7b..08e89bdfb 100644--- a/apps/api/src/lib/error.ts+++ b/apps/api/src/lib/error.ts@@ -4,6 +4,7 @@ export type ErrorCodes =| "THIRD_PARTY_DATA_TERMS_REQUIRED"| "THIRD_PARTY_DATA_NOT_FOUND"| "THIRD_PARTY_DATA_UNSUPPORTED_URL"+ | "THIRD_PARTY_DATA_UNSUPPORTED_OPTION"| "THIRD_PARTY_DATA_NOT_ENABLED"| "THIRD_PARTY_DATA_ENRICHMENT_NOT_ENABLED"| "SCRAPE_TIMEOUT"diff --git a/apps/api/src/lib/exchange-request.ts b/apps/api/src/lib/exchange-request.tsindex 9c77bf952..245f8c17e 100644--- a/apps/api/src/lib/exchange-request.ts+++ b/apps/api/src/lib/exchange-request.ts@@ -43,6 +43,7 @@ export function getExchangeAccessForRequestBody(input: {excludeTags: scrapeOptions.excludeTags ?? body.pageOptions?.excludeTags,zeroDataRetention: input.zeroDataRetention,lockdown: scrapeOptions.lockdown ?? body.lockdown,+ redactPII: scrapeOptions.redactPII,flags: input.flags,});}diff --git a/apps/api/src/lib/exchange.test.ts b/apps/api/src/lib/exchange.test.tsindex 1fb8d1ddc..d2240c15f 100644--- a/apps/api/src/lib/exchange.test.ts+++ b/apps/api/src/lib/exchange.test.ts@@ -16,10 +16,11 @@ import {getExchangeResponseLogContext,getExchangeSuccessCredits,isSuccessfulExchangeStatusCode,- isSupportedExchangeFormatRequest,+ getUnsupportedExchangeFormat,resolveExchangeProvider,setExchangeProvidersForTest,ThirdPartyDataTermsRequiredError,+ ThirdPartyDataUnsupportedOptionError,} from "./exchange";vi.mock("undici", () => ({@@ -300,25 +301,22 @@ describe("Exchange routing", () => {});it("accepts only formats derivable from the Exchange's markdown", () => {- expect(isSupportedExchangeFormatRequest(undefined)).toBe(true);- expect(isSupportedExchangeFormatRequest([{ type: "markdown" }])).toBe(true);- expect(isSupportedExchangeFormatRequest(["json"])).toBe(true);+ expect(getUnsupportedExchangeFormat(undefined)).toBeNull();+ expect(getUnsupportedExchangeFormat([{ type: "markdown" }])).toBeNull();+ expect(getUnsupportedExchangeFormat(["json"])).toBeNull();expect(- isSupportedExchangeFormatRequest([- { type: "markdown" },- { type: "json" },- ]),- ).toBe(true);- expect(isSupportedExchangeFormatRequest([{ type: "html" }])).toBe(true);- expect(isSupportedExchangeFormatRequest([{ type: "screenshot" }])).toBe(- false,+ getUnsupportedExchangeFormat([{ type: "markdown" }, { type: "json" }]),+ ).toBeNull();+ expect(getUnsupportedExchangeFormat([{ type: "html" }])).toBeNull();+ expect(getUnsupportedExchangeFormat([{ type: "screenshot" }])).toBe(+ "the `screenshot` format",);// deterministicJson extractors run against page HTML, which Exchange// responses do not carry.- expect(- isSupportedExchangeFormatRequest([{ type: "deterministicJson" }]),- ).toBe(false);- expect(isSupportedExchangeFormatRequest([])).toBe(false);+ expect(getUnsupportedExchangeFormat([{ type: "deterministicJson" }])).toBe(+ "the `deterministicJson` format",+ );+ expect(getUnsupportedExchangeFormat([])).toBe("`formats`");});it("allows eligible requests when access and terms are current", async () => {@@ -952,6 +950,18 @@ describe("Exchange terms acceptance", () => {expect(access.allowed).toBe(true);});+ it("carries the unsupported-option response through the worker queue", () => {+ const original = new ThirdPartyDataUnsupportedOptionError("`actions`");+ const error = deserializeTransportableError(+ serializeTransportableError(original),+ );++ expect(error).toBeInstanceOf(ThirdPartyDataUnsupportedOptionError);+ expect((error as ThirdPartyDataUnsupportedOptionError).response()).toEqual(+ original.response(),+ );+ });+it("carries the terms-required response through the worker queue", () => {const error = deserializeTransportableError(serializeTransportableError(diff --git a/apps/api/src/lib/exchange.ts b/apps/api/src/lib/exchange.tsindex 9f7535b3c..703a2de30 100644--- a/apps/api/src/lib/exchange.ts+++ b/apps/api/src/lib/exchange.ts@@ -43,6 +43,7 @@ type RouteInput = {excludeTags?: unknown[];zeroDataRetention?: boolean;lockdown?: boolean;+ redactPII?: unknown;flags?: {professionalProfileCompanyDataBeta?: boolean;organizationDataSourceAccess?: OrganizationDataSourceAccess | null;@@ -370,18 +371,19 @@ export function isSuccessfulExchangeStatusCode(statusCode: number): boolean {return (statusCode >= 200 && statusCode < 300) || statusCode === 304;}-export function isSupportedExchangeFormatRequest(+/** Names the first requested format the Exchange can't serve, or null when it serves them all. */+export function getUnsupportedExchangeFormat(formats?: FormatObject[] | unknown[],-): boolean {+): string | null {if (formats === undefined) {- return true;+ return null;}if (!Array.isArray(formats) || formats.length === 0) {- return false;+ return "`formats`";}- return formats.every(format => {+ for (const format of formats) {const type =typeof format === "string"? format@@ -389,8 +391,12 @@ export function isSupportedExchangeFormatRequest(? (format as { type?: unknown }).type: undefined;- return typeof type === "string" && SUPPORTED_FORMATS.has(type);- });+ if (typeof type !== "string" || !SUPPORTED_FORMATS.has(type)) {+ return typeof type === "string" ? `the \`${type}\` format` : "`formats`";+ }+ }++ return null;}type DataSourceAccessDecision = "allowed" | "terms_required" | "not_enabled";@@ -532,59 +538,67 @@ function isExchangeEligibleRequest(input: RouteInput): boolean {return false;}- if (!config.FIRE_EXCHANGE_URL) {- return false;- }+ return !!config.FIRE_EXCHANGE_URL && !!input.url;+}- if (!input.url) {- return false;+/** Names the request option that keeps the Exchange from serving the URL, or null when there is none. */+function getUnsupportedExchangeOption(input: RouteInput): string | null {+ // Named in plain words: a team policy can force it as well as the request.+ if (input.zeroDataRetention) {+ return "zero data retention";}- if (input.zeroDataRetention || input.lockdown) {- return false;+ if (input.lockdown) {+ return "`lockdown`";}if (Array.isArray(input.actions) && input.actions.length > 0) {- return false;+ return "`actions`";}// Profile-backed scrapes expect session-specific content, which the// Exchange cannot serve.if (input.profile !== undefined) {- return false;+ return "`profile`";+ }++ // PII redaction works on page text; on a provider record it would miss the+ // person's name in URLs and handles while still charging for it.+ if (input.redactPII) {+ return "`redactPII`";}// Rendering options only mean something for a real page. A blocked URL has// no page Firecrawl may render, so they are ignored there; anywhere else a// request that sets them keeps the normal engines.- if (- input.blocked !== true &&- ((input.headers !== undefined && Object.keys(input.headers).length > 0) ||- (input.waitFor !== undefined && input.waitFor !== 0) ||- input.mobile ||- input.location ||- input.blockAds === false ||- input.atsv === true ||- input.proxy === "stealth" ||- input.proxy === "enhanced" ||- (Array.isArray(input.includeTags) && input.includeTags.length > 0) ||- (Array.isArray(input.excludeTags) && input.excludeTags.length > 0))- ) {- return false;+ if (input.blocked !== true) {+ const rendering = Object.entries({+ headers:+ input.headers !== undefined && Object.keys(input.headers).length > 0,+ waitFor: input.waitFor !== undefined && input.waitFor !== 0,+ mobile: !!input.mobile,+ location: !!input.location,+ blockAds: input.blockAds === false,+ atsv: input.atsv === true,+ proxy: input.proxy === "stealth" || input.proxy === "enhanced",+ includeTags:+ Array.isArray(input.includeTags) && input.includeTags.length > 0,+ excludeTags:+ Array.isArray(input.excludeTags) && input.excludeTags.length > 0,+ }).find(([, set]) => set);+ if (rendering) {+ return `\`${rendering[0]}\``;+ }}// minAge requests ask for Firecrawl-cached data; the Exchange serves// provider data and Firecrawl never caches it, so the semantics cannot// be honored here.if (input.minAge !== undefined) {- return false;- }-- if (!isSupportedExchangeFormatRequest(input.formats)) {- return false;+ return "`minAge`";}- return true;+ return getUnsupportedExchangeFormat(input.formats);}export type ExchangeAccess =@@ -601,6 +615,8 @@ export type ExchangeAccess =| {allowed: false;termsRequired: false;+ /** Set when a provider serves the URL but this request option keeps it out. */+ unsupportedOption?: string;};export async function getExchangeAccessForRequest(@@ -619,6 +635,11 @@ export async function getExchangeAccessForRequest(return { allowed: false, termsRequired: false };}+ const unsupportedOption = getUnsupportedExchangeOption(input);+ if (unsupportedOption !== null) {+ return { allowed: false, termsRequired: false, unsupportedOption };+ }+const decision = await getProviderAccessDecision(provider, input);if (decision === "terms_required" && provider.terms !== undefined) {return { allowed: false, termsRequired: true, terms: provider.terms };@@ -713,6 +734,47 @@ export class ThirdPartyDataTermsRequiredError extends TransportableError {}}+/**+ * A provider serves the URL and nothing else may, but the request uses an+ * option the provider's data can't honor.+ */+export class ThirdPartyDataUnsupportedOptionError extends TransportableError {+ public readonly option: string;++ constructor(option: string) {+ super(+ "THIRD_PARTY_DATA_UNSUPPORTED_OPTION",+ `A third-party data provider serves this URL, but not to requests that use ${option}.`,+ );+ this.name = "ThirdPartyDataUnsupportedOptionError";+ this.option = option;+ }++ response() {+ return {+ success: false as const,+ code: "THIRD_PARTY_DATA_UNSUPPORTED_OPTION" as const,+ error: this.message,+ };+ }++ serialize() {+ return {+ ...super.serialize(),+ option: this.option,+ };+ }++ static deserialize(+ _code: ErrorCodes,+ data: ReturnType<typeof this.prototype.serialize>,+ ) {+ const x = new ThirdPartyDataUnsupportedOptionError(data.option);+ x.stack = data.stack;+ return x;+ }+}+export function getExchangeSuccessCredits(input: {exchange?: ExchangeScrapeMetadata;statusCode?: number | null;diff --git a/apps/api/src/routes/shared.ts b/apps/api/src/routes/shared.tsindex 061107393..ca0b81f99 100644--- a/apps/api/src/routes/shared.ts+++ b/apps/api/src/routes/shared.ts@@ -29,7 +29,10 @@ import {CREDITS_FEATURE_ID,} from "../services/autumn/autumn.service";import { getTeamBalance } from "../services/autumn/usage";-import { ThirdPartyDataTermsRequiredError } from "../lib/exchange";+import {+ ThirdPartyDataTermsRequiredError,+ ThirdPartyDataUnsupportedOptionError,+} from "../lib/exchange";import { getExchangeAccessForRequestBody } from "../lib/exchange-request";import { isToolsOnlySearch } from "../search/alexandria";import { getScrapeZDR } from "../lib/zdr-helpers";@@ -364,12 +367,13 @@ export function blocklistMiddleware(/*** Blocklist gate for single-URL scrape-shaped routes (scrape, crawl), where a- * blocklisted URL still passes when the exchange engine can serve it, and- * asks for the provider's terms when unaccepted terms are all that stands in- * the way. Unblocked URLs never consult the Exchange here: engine selection- * decides for them, identically on every route, and scrapes them normally- * when terms are missing. v2 batch scrape runs the same check per URL in its- * controller; map, search and monitors keep plain blocklist behavior.+ * blocklisted URL still passes when the exchange engine can serve it, asks+ * for the provider's terms when unaccepted terms are all that stands in the+ * way, and names the request option that keeps a provider out. Unblocked+ * URLs never consult the Exchange here: engine selection decides for them,+ * identically on every route, and scrapes them normally when terms are+ * missing. v2 batch scrape runs the same check per URL in its controller;+ * map, search and monitors keep plain blocklist behavior.*/export function scrapeBlocklistMiddleware(req: RequestWithMaybeACUC<any, any, any>,@@ -426,6 +430,20 @@ function blocklistGate().response(),);}++ if (+ !exchangeAccess.termsRequired &&+ exchangeAccess.unsupportedOption !== undefined &&+ !res.headersSent+ ) {+ return res+ .status(400)+ .json(+ new ThirdPartyDataUnsupportedOptionError(+ exchangeAccess.unsupportedOption,+ ).response(),+ );+ }}if (!res.headersSent) {diff --git a/apps/api/src/scraper/scrapeURL/engines/index.ts b/apps/api/src/scraper/scrapeURL/engines/index.tsindex f630fe6d6..a2481ccb0 100644--- a/apps/api/src/scraper/scrapeURL/engines/index.ts+++ b/apps/api/src/scraper/scrapeURL/engines/index.ts@@ -46,6 +46,7 @@ import { hasCustomRequestContext } from "../lib/request-context";import {getExchangeAccessForRequest,ThirdPartyDataTermsRequiredError,+ ThirdPartyDataUnsupportedOptionError,type ExchangeScrapeMetadata,} from "../../../lib/exchange";@@ -709,6 +710,7 @@ export async function buildFallbackList(meta: Meta): Promise<excludeTags: meta.options.excludeTags,zeroDataRetention: meta.internalOptions.zeroDataRetention,lockdown: meta.options.lockdown,+ redactPII: meta.options.redactPII,flags: meta.internalOptions.teamFlags ?? null,});if (exchangeAccess.allowed) {@@ -725,11 +727,16 @@ export async function buildFallbackList(meta: Meta): Promise<// or batch scrape) for the Exchange; if it can no longer serve it (catalog// changed, service down), fail closed rather than letting normal engines// scrape a blocklisted site. Unblocked URLs whose provider wants- // unaccepted terms fall through and scrape normally.+ // unaccepted terms or rejects an option fall through and scrape normally.if (blocked) {if (exchangeAccess.termsRequired) {throw new ThirdPartyDataTermsRequiredError(exchangeAccess.terms);}+ if (exchangeAccess.unsupportedOption !== undefined) {+ throw new ThirdPartyDataUnsupportedOptionError(+ exchangeAccess.unsupportedOption,+ );+ }return [];}}