abhigyanpatwari/GitNexus · error

Registry redirect missing location

Error message

Registry redirect missing location

What it means

When the registry responds with a 3xx status, fetchLatest reads the Location header to continue; if the 3xx response carries no Location header it cannot proceed and throws this error. A 3xx without Location is malformed per HTTP semantics, so it is treated as a broken response rather than silently stopping.

Source

Thrown at gitnexus/src/core/update-check.ts:189

  parsed.password = '';
  validateGitUrl(parsed.toString());
  return parsed;
}

async function fetchLatest(packageUrl: string): Promise<string> {
  let url = sanitizedHttpUrl(packageUrl);
  for (let redirects = 0; ; redirects += 1) {
    const response = await fetch(url.toString(), {
      method: 'GET',
      redirect: 'manual',
      headers: { accept: 'application/json' },
      signal: AbortSignal.timeout(FETCH_TIMEOUT_MS),
    });
    if (response.status >= 300 && response.status < 400) {
      if (redirects >= MAX_REDIRECTS) throw new Error('Too many registry redirects');
      const location = response.headers.get('location');
      await response.body?.cancel().catch(() => {});
      if (!location) throw new Error('Registry redirect missing location');
      url = sanitizedHttpUrl(location, url.toString());
      continue;
    }
    if (!response.ok) {
      await response.body?.cancel().catch(() => {});
      throw new Error(`Registry returned ${response.status}`);
    }
    const parsed = JSON.parse(await readResponseBody(response)) as {
      version?: unknown;
      'dist-tags'?: { latest?: unknown };
    };
    const latest =
      (typeof parsed.version === 'string' ? parsed.version : undefined) ??
      (typeof parsed['dist-tags']?.latest === 'string' ? parsed['dist-tags'].latest : undefined);
    if (typeof latest !== 'string' || !STRICT_UPDATE_VERSION.test(latest)) {
      throw new Error('Registry latest version is invalid');
    }
    return latest;

View on GitHub (pinned to 0d1aed942f)

Solutions

  1. Inspect the raw response (curl -i <registry-url>) to identify the device sending bare 3xxs
  2. Remove or correctly configure the intercepting proxy in front of the registry host
  3. Point the update registry URL at a host that answers directly with 200 JSON
Defensive patterns

Strategy: try-catch

Try / catch

try { const latest = await fetchLatest(url, 0); } catch (e) { if (e.message === 'Registry redirect missing location') { console.warn('Malformed 3xx from registry (no Location header); skipping update check'); } else throw e; }

Prevention

When it happens

Trigger: A proxy/load-balancer or captive portal returns 301/302/307 responses without a Location header; some anti-bot appliances emit bare 302s to intercept clients.

Common situations: Corporate filtering appliances between GitNexus and the registry; a half-broken reverse proxy in front of a private registry; a registry URL pointed at an HTML page served by a misbehaving server.

Related errors


AI-assisted analysis of abhigyanpatwari/GitNexus@0d1aed942f (2026-09-08). Data as JSON: /api/errors/22702251ee8b2532. Report an issue: GitHub.