fix: sanitize no_proxy for managed embeddings (#153)

This commit is contained in:
Andrey Avtomonov 2026-05-19 18:18:56 +02:00 committed by GitHub
parent af0567c57e
commit 8bc60e8e56
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
13 changed files with 235 additions and 180 deletions

View file

@ -0,0 +1,27 @@
const NO_PROXY_KEYS = ['NO_PROXY', 'no_proxy'] as const;
function isIpv6CidrNoProxyEntry(entry: string): boolean {
return entry.includes('/') && entry.includes(':');
}
function cleanedNoProxyValue(env: NodeJS.ProcessEnv): string | undefined {
const entries = NO_PROXY_KEYS.flatMap((key) => (env[key] ?? '').split(','))
.map((entry) => entry.trim())
.filter((entry) => entry.length > 0 && !isIpv6CidrNoProxyEntry(entry));
if (!NO_PROXY_KEYS.some((key) => env[key] !== undefined)) {
return undefined;
}
return [...new Set(entries)].join(',');
}
export function sanitizeChildProxyEnv(env: NodeJS.ProcessEnv): NodeJS.ProcessEnv {
const sanitized = { ...env };
const noProxy = cleanedNoProxyValue(env);
if (noProxy === undefined) {
return sanitized;
}
sanitized.NO_PROXY = noProxy;
sanitized.no_proxy = noProxy;
return sanitized;
}