{"record":{"id":"71af255f5b62aae3","repo":"jackwener/OpenCLI","slug":"failed-to-fetch-quote-for-symbol","errorCode":null,"errorMessage":"Failed to fetch quote for ${symbol}","messagePattern":"Failed to fetch quote for (.+?)","errorType":"exception","errorClass":"CommandExecutionError","httpStatus":null,"severity":"error","filePath":"clis/barchart/quote.js","lineNumber":114,"sourceCode":"              percentChange: changePct,\n              open: openText,\n              highPrice: dayHigh ? dayHigh.textContent.trim() : null,\n              lowPrice: dayLow ? dayLow.textContent.trim() : null,\n              previousClose: fdata['Previous Close'] || null,\n              volume: fdata['Volume'] || null,\n              averageVolume: fdata['Average Volume'] || null,\n              marketCap: null,\n              peRatio: null,\n              earningsPerShare: null,\n            }\n          };\n        } catch(e) {\n          return { error: 'Could not fetch quote for ' + sym + ': ' + e.message };\n        }\n      })()\n    `);\n        if (!data || data.error)\n            throw new CommandExecutionError(data?.error || `Failed to fetch quote for ${symbol}`);\n        const r = data.row || {};\n        // API returns formatted strings like \"+1.41\" and \"+0.56%\"; use raw if available\n        const raw = r.raw || {};\n        return [{\n                symbol: r.symbol || symbol,\n                name: r.symbolName || r.name || symbol,\n                price: r.lastPrice ?? null,\n                change: r.priceChange ?? null,\n                changePct: r.percentChange ?? null,\n                open: r.openPrice ?? r.open ?? null,\n                high: r.highPrice ?? null,\n                low: r.lowPrice ?? null,\n                prevClose: r.previousPrice ?? r.previousClose ?? null,\n                volume: r.volume ?? null,\n                avgVolume: r.averageVolume ?? null,\n                marketCap: r.marketCap ?? null,\n                peRatio: r.peRatio ?? null,\n                eps: r.earningsPerShare ?? null,","sourceCodeStart":96,"sourceCodeEnd":132,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/barchart/quote.js#L96-L132","documentation":"Fallback CommandExecutionError in `clis/barchart/quote.js:114` when the quote fetch produced no data or returned an `error` field but that error string was empty/unavailable. It wraps the inner-script failure ('Could not fetch quote for ...') or the generic message so the CLI surfaces a consistent quote-fetch error.","triggerScenarios":"`barchart quote SYMBOL` where the in-page fetch throws (network error, timeout), Barchart blocks the request, or the script returns null/undefined data.","commonSituations":"Network outage or DNS failure to barchart.com, invalid/delisted symbol, rate limiting or bot detection serving an error page, expired session.","solutions":["Read the underlying `error` message included in the thrown CommandExecutionError for the root cause.","Check network reachability of barchart.com (proxy/VPN/DNS).","Verify the symbol is valid and listed.","Retry with backoff; Barchart may be rate-limiting or blocking the client."],"exampleFix":"// before\nthrow new CommandExecutionError(data?.error || `Failed to fetch quote for ${symbol}`);\n// after\nconst msg = data?.error || `Failed to fetch quote for ${symbol}`;\nconsole.error(msg); // includes inner 'Could not fetch quote for X: <cause>'\nthrow new CommandExecutionError(msg);","handlingStrategy":"try-catch","validationCode":"function assertSymbol(s){ if (!/^[A-Z0-9.\\-]{1,10}$/.test(s)) throw new Error(`invalid symbol: ${s}`); }\n// also: const reachable = await fetch('https://barchart.com').then(r=>r.ok).catch(()=>false);","typeGuard":"const isQuotePayload = (d) => !!d && typeof d === 'object' && !d.error && (typeof d.row === 'object' || 'symbol' in (d.row||{}));","tryCatchPattern":"try {\n  const quote = await cli.run(['barchart','quote', symbol]);\n} catch (e) {\n  if (e.message.startsWith('Failed to fetch quote')) {\n    console.error(e.message); // includes inner cause\n    // check connectivity, retry with backoff\n  }\n}","preventionTips":["Read the inner cause embedded in the error message","Check network/proxy reachability of barchart.com first","Validate the symbol format before calling","Retry with exponential backoff on transient failures"],"tags":["barchart","quote","network"],"backgroundTag":"http-request-failed","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}