jackwener/OpenCLI · critical · CommandExecutionError

${label} request failed: ${err?.message ?? err}

Error message

${label} request failed: ${err?.message ?? err}

What it means

osvGet wraps the fetch call so low-level network failures (DNS resolution, connection refused/reset, TLS errors, timeouts) become CommandExecutionError with a hint to check api.osv.dev reachability. This fires before any HTTP status is available.

Source

Thrown at clis/osv/utils.js:103

async function readJson(resp, label) {
    let body;
    try {
        body = await resp.json();
    }
    catch (err) {
        throw new CommandExecutionError(`${label} returned malformed JSON: ${err?.message ?? err}`);
    }
    return body;
}

export async function osvGet(url, label) {
    let resp;
    try {
        resp = await fetch(url, { headers: { 'user-agent': UA, accept: 'application/json' } });
    }
    catch (err) {
        throw new CommandExecutionError(
            `${label} request failed: ${err?.message ?? err}`,
            'Check that api.osv.dev is reachable from this network.',
        );
    }
    if (resp.status === 404) {
        throw new EmptyResultError(label, `OSV.dev returned 404 for ${url}.`);
    }
    if (resp.status === 429) {
        throw new CommandExecutionError(`${label} returned HTTP 429 (rate limited)`);
    }
    if (!resp.ok) {
        throw new CommandExecutionError(`${label} returned HTTP ${resp.status}`);
    }
    return readJson(resp, label);
}

export async function osvPost(url, payload, label) {
    let resp;

View on GitHub (pinned to 49907e53dc)

Solutions

  1. Verify network connectivity and that https://api.osv.dev resolves (curl -I https://api.osv.dev).
  2. Check proxy configuration (HTTPS_PROXY/NO_PROXY) if behind a corporate proxy.
  3. Retry with backoff for transient outages.
  4. Check firewall/egress rules allow HTTPS to api.osv.dev.

Example fix

// before
const body = await osvGet(url, label); // throws on network failure
// after
try {
  const body = await osvGet(url, label);
} catch (e) {
  if (/request failed/.test(e.message)) {
    console.error('api.osv.dev unreachable; check network/proxy');
  }
  throw e;
}
Defensive patterns

Strategy: retry

Validate before calling

const reachable = await fetch('https://api.osv.dev/v1/query', { method: 'HEAD' })
  .then((r) => true)
  .catch(() => false);
if (!reachable) throw new Error('api.osv.dev is not reachable; check network/proxy before running OSV queries');

Type guard

const isNetworkError = (err) =>
  err instanceof Error && /fetch failed|ENOTFOUND|ECONNREFUSED|EAI_AGAIN|certificate|timeout/i.test(err.message);

Try / catch

try {
  const body = await osvGet(url, label);
} catch (e) {
  if (e instanceof CommandExecutionError && /request failed/.test(e.message)) {
    console.error('api.osv.dev unreachable — checking connectivity');
    return retryWithBackoff(() => osvGet(url, label), 3, 500);
  }
  throw e;
}

Prevention

When it happens

Trigger: fetch() rejects: no DNS entry for api.osv.dev, connection refused, TLS handshake failure, offline network, or a proxy blocking the request.

Common situations: Being offline or on a restricted corporate network; DNS blocked for api.osv.dev; firewall egress rules; misconfigured HTTPS_PROXY; transient network outage.

Related errors


AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29). Data as JSON: /api/errors/21ca9a4c118a5e5c. Report an issue: GitHub.