{"record":{"id":"7f588cda2fa0d107","repo":"jackwener/OpenCLI","slug":"barchart-greeks-request-failed-data-message","errorCode":null,"errorMessage":"Barchart greeks request failed: ${data.message || 'unknown error'}","messagePattern":"Barchart greeks request failed: (.+?)","errorType":"exception","errorClass":"CommandExecutionError","httpStatus":null,"severity":"error","filePath":"clis/barchart/greeks.js","lineNumber":166,"sourceCode":"                openInterest: r.openInterest,\n                expiration: r.expirationDate,\n              };\n            })\n          };\n        } catch(e) {\n          return { ok: false, reason: 'exception', message: e?.message || String(e) };\n        }\n      })()\n    `));\n        if (!data || data.ok !== true) {\n            if (data?.reason === 'http') {\n                throw new CommandExecutionError(`Barchart greeks request failed: HTTP ${data.status}${data.statusText ? ` ${data.statusText}` : ''}`);\n            }\n            if (data?.reason === 'malformed') {\n                throw new CommandExecutionError(`Barchart greeks returned an unreadable options payload${data.message ? `: ${data.message}` : ''}`);\n            }\n            if (data?.reason === 'exception') {\n                throw new CommandExecutionError(`Barchart greeks request failed: ${data.message || 'unknown error'}`);\n            }\n            throw new CommandExecutionError(`Failed to fetch Barchart greeks for ${symbol}`);\n        }\n        if (!Array.isArray(data.rows)) {\n            throw new CommandExecutionError('Barchart greeks returned an unreadable options payload');\n        }\n        if (data.rows.length === 0) {\n            throw new EmptyResultError('barchart greeks', `No option greeks were returned for ${symbol}. Confirm the symbol, expiration, and Barchart login state.`);\n        }\n        return data.rows.map(r => {\n            if (!r || typeof r !== 'object' || Array.isArray(r)) {\n                throw new CommandExecutionError('Barchart greeks returned a malformed option row');\n            }\n            const type = String(r.type || '').trim();\n            const expirationValue = String(r.expiration || '').trim();\n            if (!/^(call|put)$/i.test(type) || r.strike === undefined || r.strike === null || r.strike === '' || !expirationValue) {\n                throw new CommandExecutionError('Barchart greeks returned a malformed option row identity');\n            }","sourceCodeStart":148,"sourceCodeEnd":184,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/barchart/greeks.js#L148-L184","documentation":"When the in-browser evaluation itself threw an exception, the wrapper catches it and returns { ok:false, reason:'exception', message }, and the CLI re-raises it as this CommandExecutionError. The message carries the underlying exception text (or 'unknown error'), so it reflects whatever failed inside the browser context — navigation failure, blocked fetch, script error, etc.","triggerScenarios":"The evaluation script threw: fetch() rejected (network down, DNS failure, TLS error), page navigation failed, the target element was missing and code dereferenced undefined, or any other uncaught error inside the browser sandbox.","commonSituations":"No internet connection or DNS problems; Barchart blocking the automated context; headless browser not started or crashed; timeout on slow networks; a Barchart page change causing a null reference inside the extraction script.","solutions":["Read data.message in the error text to identify the underlying exception, then fix that root cause.","Verify general network connectivity and that barchart.com is reachable.","Ensure the browser/session the CLI drives is running and logged in, then retry.","If the message indicates a script error on Barchart's page, retry later or update the extraction script for the new page structure."],"exampleFix":"// before\nconst data = await unwrapBrowserResult(await browserEval(script));\n// after\nlet data;\ntry {\n  data = await unwrapBrowserResult(await browserEval(script));\n} catch (e) {\n  throw new CommandExecutionError(`Barchart greeks request failed: ${e.message}`);\n}","handlingStrategy":"try-catch","validationCode":"// Check browser context health before evaluation\nif (!browser || !browser.isConnected()) {\n  await launchBrowser();\n}\nawait page.goto('https://www.barchart.com', { waitUntil: 'domcontentloaded', timeout: 30000 });","typeGuard":"function isExceptionFailure(data) {\n  return data !== null && typeof data === 'object' && data.ok === false && data.reason === 'exception';\n}","tryCatchPattern":"try {\n  const rows = await greeks({ symbol });\n} catch (e) {\n  if (e.message.startsWith('Barchart greeks request failed:') && !e.message.includes('HTTP')) {\n    console.error(`Browser evaluation threw: ${e.message}`);\n    await restartBrowser();\n    return greeks({ symbol });\n  }\n  throw e;\n}","preventionTips":["Verify network connectivity and DNS before automating","Ensure the headless browser is running and the session is valid","Set generous timeouts for slow networks; log the underlying exception message"],"tags":["network","browser-automation","barchart","exception"],"backgroundTag":"browser-evaluation-failed","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}