Skip to content

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

feat(scrapeURL/skipTlsVerification): improve error message (#1723)

Gergő Móricz55d5c1f41dd6
diff --git a/apps/api/src/scraper/scrapeURL/engines/fire-engine/checkStatus.ts b/apps/api/src/scraper/scrapeURL/engines/fire-engine/checkStatus.ts
index 44222db76..850b4c964 100644
--- a/apps/api/src/scraper/scrapeURL/engines/fire-engine/checkStatus.ts
+++ b/apps/api/src/scraper/scrapeURL/engines/fire-engine/checkStatus.ts
@@ -13,6 +13,7 @@ import {
import { MockState } from "../../lib/mock";
import { fireEngineURL } from "./scrape";
import { getDocFromGCS } from "../../../../lib/gcs-jobs";
+import { Meta } from "../..";
const successSchema = z.object({
jobId: z.string(),
@@ -123,6 +124,7 @@ export class StillProcessingError extends Error {
}
export async function fireEngineCheckStatus(
+ meta: Meta,
logger: Logger,
jobId: string,
mock: MockState | null,
@@ -181,7 +183,7 @@ export async function fireEngineCheckStatus(
const code = status.error.split("Chrome error: ")[1];
if (code.includes("ERR_CERT_") || code.includes("ERR_SSL_") || code.includes("ERR_BAD_SSL_")) {
- throw new SSLError();
+ throw new SSLError(meta.options.skipTlsVerification);
} else {
throw new SiteError(code);
}
diff --git a/apps/api/src/scraper/scrapeURL/engines/fire-engine/index.ts b/apps/api/src/scraper/scrapeURL/engines/fire-engine/index.ts
index 91cea606f..b4babf308 100644
--- a/apps/api/src/scraper/scrapeURL/engines/fire-engine/index.ts
+++ b/apps/api/src/scraper/scrapeURL/engines/fire-engine/index.ts
@@ -37,6 +37,7 @@ async function performFireEngineScrape<
| FireEngineScrapeRequestPlaywright
| FireEngineScrapeRequestTLSClient,
>(
+ meta: Meta,
logger: Logger,
request: FireEngineScrapeRequestCommon & Engine,
timeout: number,
@@ -85,6 +86,7 @@ async function performFireEngineScrape<
try {
status = await fireEngineCheckStatus(
+ meta,
logger.child({ method: "fireEngineCheckStatus" }),
scrape.jobId,
mock,
@@ -231,6 +233,7 @@ export async function scrapeURLWithFireEngineChromeCDP(
};
let response = await performFireEngineScrape(
+ meta,
meta.logger.child({
method: "scrapeURLWithFireEngineChromeCDP/callFireEngine",
request,
@@ -317,6 +320,7 @@ export async function scrapeURLWithFireEnginePlaywright(
};
let response = await performFireEngineScrape(
+ meta,
meta.logger.child({
method: "scrapeURLWithFireEngineChromeCDP/callFireEngine",
request,
@@ -377,6 +381,7 @@ export async function scrapeURLWithFireEngineTLSClient(
};
let response = await performFireEngineScrape(
+ meta,
meta.logger.child({
method: "scrapeURLWithFireEngineChromeCDP/callFireEngine",
request,
diff --git a/apps/api/src/scraper/scrapeURL/error.ts b/apps/api/src/scraper/scrapeURL/error.ts
index 16a9212f5..a47f5a86a 100644
--- a/apps/api/src/scraper/scrapeURL/error.ts
+++ b/apps/api/src/scraper/scrapeURL/error.ts
@@ -50,8 +50,13 @@ export class RemoveFeatureError extends Error {
}
export class SSLError extends Error {
- constructor() {
- super("An SSL error occurred while scraping the URL. If you're not inputting any sensitive data, try scraping with `skipTlsVerification: true`.");
+ constructor(skipTlsVerification: boolean) {
+ super(
+ "An SSL error occurred while scraping the URL. "
+ + (skipTlsVerification
+ ? "Since you have `skipTlsVerification` enabled, this means that the TLS configuration of the target site is completely broken. Try scraping the plain HTTP version of the page."
+ : "If you're not inputting any sensitive data, try scraping with `skipTlsVerification: true`.")
+ );
}
}