diff --git a/server/utils/fetch.ts b/server/utils/fetch.ts index c6fc3f95d2..6c59e6a555 100644 --- a/server/utils/fetch.ts +++ b/server/utils/fetch.ts @@ -11,7 +11,7 @@ import nodeFetch, { import { getProxyForUrl } from "proxy-from-env"; import tunnelAgent, { type TunnelAgent } from "tunnel-agent"; import env from "@server/env"; -import { InternalError } from "@server/errors"; +import { InvalidRequestError } from "@server/errors"; import Logger from "@server/logging/Logger"; import { capitalize } from "es-toolkit/compat"; import { @@ -184,9 +184,11 @@ export default async function fetch( if (err.name === "AbortError") { throw new Error(`Request timeout after ${timeout}ms`); } - if (!env.isCloudHosted && err.message?.startsWith("DNS lookup")) { - throw InternalError( - `${err.message}\n\nTo allow this request, add the IP address or CIDR range to the ALLOWED_PRIVATE_IP_ADDRESSES environment variable.` + if (err.message?.startsWith("DNS lookup")) { + throw InvalidRequestError( + env.isCloudHosted + ? err.message + : `${err.message}\n\nTo allow this request, add the IP address or CIDR range to the ALLOWED_PRIVATE_IP_ADDRESSES environment variable.` ); } throw err;