{"record":{"id":"e4e5eb40188eed38","repo":"jackwener/OpenCLI","slug":"symbol-is-required","errorCode":null,"errorMessage":"symbol is required","messagePattern":"symbol is required","errorType":"validation","errorClass":"ArgumentError","httpStatus":null,"severity":"error","filePath":"clis/barchart/greeks.js","lineNumber":15,"sourceCode":"/**\n * Barchart options greeks overview — IV, delta, gamma, theta, vega, rho\n * for near-the-money options on a given symbol.\n * Auth: CSRF token from <meta name=\"csrf-token\"> + session cookies.\n */\nimport { cli, Strategy } from '@jackwener/opencli/registry';\nimport { ArgumentError, CommandExecutionError, EmptyResultError } from '@jackwener/opencli/errors';\n\nconst DEFAULT_LIMIT = 10;\nconst MIN_LIMIT = 1;\nconst MAX_LIMIT = 100;\n\nfunction normalizeSymbol(value) {\n    const symbol = String(value ?? '').trim().toUpperCase();\n    if (!symbol) throw new ArgumentError('symbol is required');\n    return symbol;\n}\n\nfunction normalizeExpiration(value) {\n    const expiration = String(value ?? '').trim();\n    if (!expiration) return '';\n    if (!/^\\d{4}-\\d{2}-\\d{2}$/.test(expiration)) {\n        throw new ArgumentError('--expiration must use YYYY-MM-DD format');\n    }\n    const parsed = new Date(`${expiration}T00:00:00Z`);\n    if (Number.isNaN(parsed.getTime()) || parsed.toISOString().slice(0, 10) !== expiration) {\n        throw new ArgumentError('--expiration must be a valid calendar date');\n    }\n    return expiration;\n}\n\nfunction parseLimit(value) {\n    if (value === undefined || value === null || value === '') return DEFAULT_LIMIT;","sourceCodeStart":1,"sourceCodeEnd":33,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/barchart/greeks.js#L1-L33","documentation":"normalizeSymbol() coerces the --symbol argument to a trimmed uppercase string and throws an ArgumentError if the result is empty. This guards the Barchart greeks command, which cannot build a request without a ticker symbol. It fires for missing, null, or whitespace-only symbol values.","triggerScenarios":"Calling the barchart greeks command/API without --symbol, with --symbol=\"\", or with a value that is only whitespace, or passing null/undefined programmatically to the `symbol` option handler.","commonSituations":"Forgetting the --symbol flag on the command line; shell variables that expand to empty ($SYMBOL unset); scripts passing an empty ticker after stripping; configuration files with a blank symbol field.","solutions":["Pass a non-empty ticker, e.g. --symbol AAPL.","Check that any shell variable used for the symbol is actually set and non-blank before invoking the command.","Validate/trim the symbol in your wrapper script before calling the CLI."],"exampleFix":"// before\nawait greeks({ symbol: process.env.TICKER }); // TICKER may be empty\n// after\nconst symbol = (process.env.TICKER || '').trim();\nif (!symbol) throw new Error('TICKER env var must be set to a ticker symbol');\nawait greeks({ symbol });","handlingStrategy":"validation","validationCode":"function requireSymbol(value) {\n  const s = String(value ?? '').trim().toUpperCase();\n  if (!s) throw new Error('symbol is required');\n  return s;\n}\n// call: requireSymbol(process.env.TICKER)","typeGuard":"function isValidSymbol(v) {\n  return typeof v === 'string' && v.trim().length > 0;\n}","tryCatchPattern":"try {\n  await greeks({ symbol });\n} catch (e) {\n  if (e.name === 'ArgumentError' && /symbol is required/.test(e.message)) {\n    console.error('Usage: greeks --symbol <TICKER>');\n    process.exitCode = 2;\n    return;\n  }\n  throw e;\n}","preventionTips":["Always pass --symbol explicitly; never rely on unset env vars","Trim and uppercase tickers in wrapper scripts","Add an argument-count check in automation scripts before invoking the CLI"],"tags":["validation","argument-error","cli","missing-argument"],"backgroundTag":"missing-required-argument","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}