jackwener/OpenCLI · error · CommandExecutionError
Failed to fetch Barchart greeks for ${symbol}
Error message
Failed to fetch Barchart greeks for ${symbol} What it means
This fallback CommandExecutionError is thrown when the greeks envelope reports ok !== true but none of the known reasons ('http', 'malformed', 'exception') matched — an unexpected envelope shape. The requested symbol is interpolated into the message to aid debugging. It indicates an unrecognized failure mode from the browser evaluation layer.
Source
Thrown at clis/barchart/greeks.js:168
};
})
};
} 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();
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,View on GitHub (pinned to 49907e53dc)
Solutions
- Run the command with verbose/debug output if available to inspect the raw browser-evaluation return value.
- Re-run the command once — transient navigation/timing issues often produce undefined returns.
- Verify the browser session and page load: open the greeks page manually to confirm it loads for your session.
- If you modified the evaluation script, restore its return path so it always resolves to { ok: true, rows } or a { ok:false, reason } envelope.
Example fix
// before
return; // early return yields undefined -> 'Failed to fetch ...'
// after
return { ok: false, reason: 'malformed', message: 'no rows container found' }; Defensive patterns
Strategy: fallback
Validate before calling
// Ensure the evaluation layer always returns a recognized envelope
const raw = await browserEval(script);
if (raw === undefined || raw === null) {
console.warn('Browser evaluation returned nothing — page may have navigated away');
} Type guard
function hasKnownReason(v) {
return v !== null && typeof v === 'object' && typeof v.ok === 'boolean' &&
(v.ok || ['http', 'malformed', 'exception'].includes(v.reason));
} Try / catch
async function safeGreeks(symbol) {
try {
return await greeks({ symbol });
} catch (e) {
if (e.message.startsWith('Failed to fetch Barchart greeks')) {
await new Promise(r => setTimeout(r, 3000));
return greeks({ symbol }); // one retry; transient undefined returns are common
}
throw e;
}
} Prevention
- Always return a { ok, reason|rows } envelope from evaluation scripts — never undefined
- Retry once on this fallback error; it is often a transient timing/navigation issue
- Keep the wrapper script and in-page script versions in sync
When it happens
Trigger: The browser evaluation returned a falsy value (data undefined/null) or an object with ok !== true and no recognized reason field — e.g. the script's returned expression evaluated to undefined because the IIFE returned nothing, or unwrapBrowserResult got an unexpected shape.
Common situations: Browser context returning undefined after a silent script failure or page navigation; a version mismatch where the wrapper script no longer emits the expected {ok, reason} envelope; premature page close discarding the return value; editing the in-page script so its return path was dropped.
Related errors
- Could not extract CSRF token from barchart.com. Make sure yo
- Barchart greeks request failed: HTTP ${data.status}${data.st
- Barchart greeks returned an unreadable options payload${data
- Barchart greeks request failed: ${data.message || 'unknown e
- Barchart greeks returned an unreadable options payload
AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29).
Data as JSON: /api/errors/f17c6aa3a01401fa.
Report an issue: GitHub.