jackwener/OpenCLI · error · CommandExecutionError

Barchart greeks request failed: HTTP ${data.status}${data.st

Error message

Barchart greeks request failed: HTTP ${data.status}${data.statusText ? ` ${data.statusText}` : ''}

What it means

The greeks command runs an in-browser fetch and inspects the returned envelope. When the envelope reports reason:'http', meaning Barchart answered with a non-OK HTTP status, the CLI raises this CommandExecutionError with the status code and optional status text. It signals the remote request itself failed rather than an argument problem.

Source

Thrown at clis/barchart/greeks.js:160

                delta: r.delta,
                gamma: r.gamma,
                theta: r.theta,
                vega: r.vega,
                rho: r.rho,
                volume: r.volume,
                openInterest: r.openInterest,
                expiration: r.expirationDate,
              };
            })
          };
        } catch(e) {
          return { ok: false, reason: 'exception', message: e?.message || String(e) };
        }
      })()
    `));
        if (!data || data.ok !== true) {
            if (data?.reason === 'http') {
                throw new CommandExecutionError(`Barchart greeks request failed: HTTP ${data.status}${data.statusText ? ` ${data.statusText}` : ''}`);
            }
            if (data?.reason === 'malformed') {
                throw new CommandExecutionError(`Barchart greeks returned an unreadable options payload${data.message ? `: ${data.message}` : ''}`);
            }
            if (data?.reason === 'exception') {
                throw new CommandExecutionError(`Barchart greeks request failed: ${data.message || 'unknown error'}`);
            }
            throw new CommandExecutionError(`Failed to fetch Barchart greeks for ${symbol}`);
        }
        if (!Array.isArray(data.rows)) {
            throw new CommandExecutionError('Barchart greeks returned an unreadable options payload');
        }
        if (data.rows.length === 0) {
            throw new EmptyResultError('barchart greeks', `No option greeks were returned for ${symbol}. Confirm the symbol, expiration, and Barchart login state.`);
        }
        return data.rows.map(r => {
            if (!r || typeof r !== 'object' || Array.isArray(r)) {
                throw new CommandExecutionError('Barchart greeks returned a malformed option row');

View on GitHub (pinned to 49907e53dc)

Solutions

  1. Read the HTTP status in the message: re-login if 401/403, back off if 429, retry later if 5xx.
  2. Refresh your Barchart session/cookies and confirm you can load the greeks page while logged in.
  3. Retry after a delay with rate limiting (the command is safe to rerun).
  4. If a specific status persists (e.g. 404), check whether Barchart changed its endpoint URLs.

Example fix

// before
const rows = await greeks({ symbol: 'AAPL' }); // throws on any HTTP error
// after
let rows;
try {
  rows = await greeks({ symbol: 'AAPL' });
} catch (e) {
  if (/HTTP 4/.test(e.message)) await relogin();
  await sleep(2000);
  rows = await greeks({ symbol: 'AAPL' });
}
Defensive patterns

Strategy: retry

Validate before calling

// Probe reachability + login state before the real call
const probe = await fetch('https://www.barchart.com', { headers: { cookie: cookies } });
if (probe.status === 401 || probe.status === 403) throw new Error('Barchart session expired');

Type guard

function isHttpFailure(data) {
  return data !== null && typeof data === 'object' && data.ok === false && data.reason === 'http';
}

Try / catch

async function withRetry(fn, attempts = 3) {
  for (let i = 0; i < attempts; i++) {
    try {
      return await fn();
    } catch (e) {
      const status = /HTTP (\d{3})/.exec(e.message)?.[1];
      const retryable = status && (status.startsWith('4') ? status === '429' : status.startsWith('5'));
      if (!retryable || i === attempts - 1) throw e;
      await new Promise(r => setTimeout(r, 2000 * 2 ** i));
    }
  }
}

Prevention

When it happens

Trigger: The browser-context fetch to Barchart's greeks endpoint returned data.ok !== true with reason:'http' — e.g. HTTP 401/403 when not logged in, HTTP 404 for a bad endpoint, HTTP 429 rate limiting, or HTTP 5xx from Barchart.

Common situations: Expired Barchart login session (401/403); hitting the endpoint too frequently (429); Barchart outage or maintenance (5xx); corporate proxy/firewall altering responses; option symbol variants the endpoint rejects.

Understand the failure class

Background: 'Something went wrong' / 'Request failed (500)' / 'HTTP error! status: 404' — what failed HTTP requests actually mean and how to find the real cause — this error's family across 28 libraries.

Related errors


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