jackwener/OpenCLI · error · CommandExecutionError
Barchart greeks returned a malformed option row
Error message
Barchart greeks returned a malformed option row
What it means
Thrown while mapping Barchart greek rows when an individual row is not a plain object (null, non-object, or an array). The library treats each row as a record with type/strike/expiration fields; a row violating that shape aborts the whole command with this CommandExecutionError.
Source
Thrown at clis/barchart/greeks.js:178
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();
if (!/^(call|put)$/i.test(type) || r.strike === undefined || r.strike === null || r.strike === '' || !expirationValue) {
throw new CommandExecutionError('Barchart greeks returned a malformed option row identity');
}
return {
type,
strike: r.strike,
last: r.last != null ? Number(Number(r.last).toFixed(2)) : null,
iv: r.iv != null ? Number(Number(r.iv).toFixed(2)) + '%' : null,
delta: r.delta != null ? Number(Number(r.delta).toFixed(4)) : null,
gamma: r.gamma != null ? Number(Number(r.gamma).toFixed(4)) : null,
theta: r.theta != null ? Number(Number(r.theta).toFixed(4)) : null,
vega: r.vega != null ? Number(Number(r.vega).toFixed(4)) : null,
rho: r.rho != null ? Number(Number(r.rho).toFixed(4)) : null,
volume: r.volume,
openInterest: r.openInterest,View on GitHub (pinned to 49907e53dc)
Solutions
- Log the offending row to see the actual shape Barchart returned.
- Filter out non-object rows before mapping.
- Update the CLI to match the current Barchart row schema.
- Retry after re-authenticating if a degraded/scraped page was served.
Example fix
// before
return data.rows.map(r => { if (!r || typeof r !== 'object' || Array.isArray(r)) throw ...; });
// after
return data.rows.filter(r => r && typeof r === 'object' && !Array.isArray(r)).map(r => { /* map fields */ }); Defensive patterns
Strategy: type-guard
Validate before calling
const validRow = (r) => r && typeof r === 'object' && !Array.isArray(r); rows.filter(validRow).map(/* ... */);
Type guard
const isOptionRow = (r) => typeof r === 'object' && r !== null && !Array.isArray(r);
Try / catch
try {
const rows = await cli.run(['barchart','greeks', symbol]);
} catch (e) {
if (e.message.includes('malformed option row')) {
// dump and sanitize rows, skip bad entries, retry
}
} Prevention
- Sanitize/filter rows before mapping
- Keep the CLI updated for Barchart schema drift
- Log the raw payload when a row fails validation
- Treat scraping output as untrusted input
When it happens
Trigger: Barchart returning rows containing null placeholders, or a payload where `rows` is an array of arrays/strings instead of objects after a schema change.
Common situations: Partial page renders during scraping, Barchart API format drift, mixing cached and fresh payloads, rows padded with nulls for illiquid strikes.
Understand the failure class
- Parsing and encoding errors: unexpected token, malformed input — why parsers reject input and how to find the real culprit.
Related errors
- Barchart greeks returned a malformed option row identity
- archive snapshots returned malformed CDX payload: snapshot r
- Barchart greeks returned an unreadable options payload
- No option greeks were returned for ${symbol}. Confirm the sy
- 12306 ${endpoint} returned an unexpected payload shape
AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29).
Data as JSON: /api/errors/e7ce92052741bb42.
Report an issue: GitHub.