jackwener/OpenCLI · error · CommandExecutionError

Barchart greeks returned an unreadable options payload${data

Error message

Barchart greeks returned an unreadable options payload${data.message ? `: ${data.message}` : ''}

What it means

When the in-browser evaluation completes but its result cannot be interpreted — data.ok !== true with reason:'malformed' — the CLI throws this CommandExecutionError. The optional data.message appends what specifically was unreadable. It means the response arrived but did not match the expected greeks payload shape.

Source

Thrown at clis/barchart/greeks.js:163

                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');
            }
            const type = String(r.type || '').trim();
            const expirationValue = String(r.expiration || '').trim();

View on GitHub (pinned to 49907e53dc)

Solutions

  1. Check the appended data.message for what was unreadable, then open the greeks page in a browser to see what is actually returned.
  2. Re-login to Barchart if the page is returning login HTML instead of data.
  3. Complete any CAPTCHA/bot-challenge in the browser session, then retry.
  4. If Barchart changed its payload schema, update the extraction/parsing script to the new shape.

Example fix

// before
if (!data || data.ok !== true) throw new CommandExecutionError('unreadable payload');
// after
if (!data || data.ok !== true) {
  if (typeof data?.body === 'string' && data.body.includes('Sign In')) {
    throw new CommandExecutionError('Barchart session expired — got login page');
  }
  throw new CommandExecutionError('unreadable payload');
}
Defensive patterns

Strategy: type-guard

Validate before calling

// Confirm the page returns data, not a login/interstitial, before parsing
const html = await page.content();
if (/sign in|captcha|access denied/i.test(html)) {
  throw new Error('Barchart returned an interstitial page — authenticate first');
}

Type guard

function isGreeksEnvelope(v) {
  return v !== null && typeof v === 'object' &&
    (v.ok === true ? Array.isArray(v.rows) : ['http', 'malformed', 'exception'].includes(v.reason));
}

Try / catch

try {
  const rows = await greeks({ symbol });
} catch (e) {
  if (e.message.includes('unreadable options payload')) {
    await refreshSession(); // likely got login HTML or a bot challenge
    return greeks({ symbol });
  }
  throw e;
}

Prevention

When it happens

Trigger: The browser-context script returned { ok: false, reason: 'malformed', message } because the fetched body was not parseable as the expected options payload — e.g. HTML instead of JSON (login page, bot challenge) or a changed schema.

Common situations: Barchart serving an anti-bot/Cloudflare-style interstitial page; being logged out so a login HTML page is returned; Barchart changing the greeks response schema after a site update; truncated responses on flaky connections.

Related errors


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