{"record":{"id":"fecb1dbcb9c07413","repo":"jackwener/OpenCLI","slug":"oeis-sequence-id-is-required-e-g-a000045-for-f","errorCode":null,"errorMessage":"oeis sequence id is required (e.g. \"A000045\" for Fibonacci)","messagePattern":"oeis sequence id is required \\(e\\.g\\. \"A000045\" for Fibonacci\\)","errorType":"validation","errorClass":"ArgumentError","httpStatus":null,"severity":"error","filePath":"clis/oeis/utils.js","lineNumber":34,"sourceCode":"    if (!s) throw new ArgumentError(`oeis ${label} cannot be empty`);\n    return s;\n}\n\nexport function requireBoundedInt(value, defaultValue, maxValue, label = 'limit') {\n    const raw = value ?? defaultValue;\n    const n = typeof raw === 'number' ? raw : Number(raw);\n    if (!Number.isInteger(n) || n <= 0) {\n        throw new ArgumentError(`oeis ${label} must be a positive integer`);\n    }\n    if (n > maxValue) {\n        throw new ArgumentError(`oeis ${label} must be <= ${maxValue}`);\n    }\n    return n;\n}\n\nexport function requireSequenceId(value) {\n    const raw = String(value ?? '').trim().toUpperCase();\n    if (!raw) throw new ArgumentError('oeis sequence id is required (e.g. \"A000045\" for Fibonacci)');\n    // Tolerate common URL paste like `https://oeis.org/A000045`.\n    const stripped = raw.replace(/^HTTPS?:\\/\\/(?:WWW\\.)?OEIS\\.ORG\\//, '').replace(/\\/.*$/, '');\n    if (!SEQUENCE_ID_PATTERN.test(stripped)) {\n        throw new ArgumentError(\n            `oeis sequence id \"${value}\" is not a valid A-number`,\n            'Expected format: \"A\" + digits (e.g. \"A000045\").',\n        );\n    }\n    return stripped;\n}\n\nexport async function oeisFetch(url, label) {\n    let resp;\n    try {\n        resp = await fetch(url, { headers: { 'user-agent': UA, accept: 'application/json' } });\n    }\n    catch (err) {\n        throw new CommandExecutionError(","sourceCodeStart":16,"sourceCodeEnd":52,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/oeis/utils.js#L16-L52","documentation":"requireSequenceId converts its argument to a trimmed, uppercased string and throws this ArgumentError when the result is empty. Every OEIS lookup needs an A-number (like A000045), so an absent id cannot proceed. The function also tolerates pasted OEIS URLs before validating the format.","triggerScenarios":"Calling the `id` command/path with no argument, an empty string, or a value that is only whitespace (e.g. requireSequenceId('   ') or `oeis id \"\"`).","commonSituations":"Forgetting the positional argument on the command line, or a shell variable like $SEQ being unset so the script passes an empty value.","solutions":["Provide a sequence id, e.g. `oeis id A000045`.","Check that the variable holding the id is actually set and non-empty.","Use the full OEIS URL if easier — it is accepted and parsed (e.g. https://oeis.org/A000045)."],"exampleFix":"// before\noeis id \"$SEQ\"   # SEQ is empty\n// after\noeis id A000045","handlingStrategy":"validation","validationCode":"if (!id || !String(id).trim()) throw new Error('A sequence id is required, e.g. A000045');","typeGuard":"function hasSequenceId(v) { return typeof v === 'string' && v.trim().length > 0; }","tryCatchPattern":"try { const sid = requireSequenceId(opts.id); } catch (e) { console.error(e.message); process.exitCode = 1; }","preventionTips":["Check shell variables are non-empty before interpolation: ${SEQ:?SEQ not set}.","Make the id a required positional argument in your wrappers.","Default missing input to an interactive prompt or usage message."],"tags":["validation","input","missing-argument"],"backgroundTag":"missing-required-argument","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}