fix: Private IP lookup should be invalid request rather than internal error (#12592)

This commit is contained in:
Tom Moor
2026-06-05 09:19:05 -04:00
committed by GitHub
parent 88de417a21
commit e864684d56
+6 -4
View File
@@ -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;