jackwener/OpenCLI · error · ArgumentError
oeis sequence id is required (e.g. "A000045" for Fibonacci)
Error message
oeis sequence id is required (e.g. "A000045" for Fibonacci)
What it means
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.
Source
Thrown at clis/oeis/utils.js:34
if (!s) throw new ArgumentError(`oeis ${label} cannot be empty`);
return s;
}
export function requireBoundedInt(value, defaultValue, maxValue, label = 'limit') {
const raw = value ?? defaultValue;
const n = typeof raw === 'number' ? raw : Number(raw);
if (!Number.isInteger(n) || n <= 0) {
throw new ArgumentError(`oeis ${label} must be a positive integer`);
}
if (n > maxValue) {
throw new ArgumentError(`oeis ${label} must be <= ${maxValue}`);
}
return n;
}
export function requireSequenceId(value) {
const raw = String(value ?? '').trim().toUpperCase();
if (!raw) throw new ArgumentError('oeis sequence id is required (e.g. "A000045" for Fibonacci)');
// Tolerate common URL paste like `https://oeis.org/A000045`.
const stripped = raw.replace(/^HTTPS?:\/\/(?:WWW\.)?OEIS\.ORG\//, '').replace(/\/.*$/, '');
if (!SEQUENCE_ID_PATTERN.test(stripped)) {
throw new ArgumentError(
`oeis sequence id "${value}" is not a valid A-number`,
'Expected format: "A" + digits (e.g. "A000045").',
);
}
return stripped;
}
export async function oeisFetch(url, label) {
let resp;
try {
resp = await fetch(url, { headers: { 'user-agent': UA, accept: 'application/json' } });
}
catch (err) {
throw new CommandExecutionError(View on GitHub (pinned to 49907e53dc)
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).
Example fix
// before oeis id "$SEQ" # SEQ is empty // after oeis id A000045
Defensive patterns
Strategy: validation
Validate before calling
if (!id || !String(id).trim()) throw new Error('A sequence id is required, e.g. A000045'); Type guard
function hasSequenceId(v) { return typeof v === 'string' && v.trim().length > 0; } Try / catch
try { const sid = requireSequenceId(opts.id); } catch (e) { console.error(e.message); process.exitCode = 1; } Prevention
- 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.
When it happens
Trigger: Calling the `id` command/path with no argument, an empty string, or a value that is only whitespace (e.g. requireSequenceId(' ') or `oeis id ""`).
Common situations: Forgetting the positional argument on the command line, or a shell variable like $SEQ being unset so the script passes an empty value.
Understand the failure class
Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.
Related errors
- archive search sort must be one of ${SORT_OPTIONS.join(', ')
- archive search mediatype must be one of ${MEDIATYPES.join(',
- archive search limit must be a positive integer
- archive search query must not be empty
- arxiv author cannot be empty
AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29).
Data as JSON: /api/errors/fecb1dbcb9c07413.
Report an issue: GitHub.