jackwener/OpenCLI · error · ArgumentError

oeis sequence id "${value}" is not a valid A-number

Error message

oeis sequence id "${value}" is not a valid A-number

What it means

requireSequenceId validates the id against SEQUENCE_ID_PATTERN (an 'A' followed by digits) after stripping a pasted oeis.org URL prefix and any trailing path. If the cleaned value still does not match, it throws this ArgumentError with a hint about the expected 'A' + digits format. The original input is echoed in the message.

Source

Thrown at clis/oeis/utils.js:38

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(
            `${label} request failed: ${err?.message ?? err}`,
            'Check that oeis.org is reachable from this network.',
        );
    }

View on GitHub (pinned to 49907e53dc)

Solutions

  1. Use the canonical A-number format: 'A' + 6 digits, e.g. A000045.
  2. Look up the sequence on oeis.org and copy its id.
  3. If pasting a URL, ensure it is an https?://(www.)oeis.org/... link.

Example fix

// before
oeis id Fibonacci
// after
oeis id A000045
Defensive patterns

Strategy: validation

Validate before calling

const cleaned = String(id ?? '').trim().toUpperCase().replace(/^HTTPS?:\/\/(?:WWW\.)?OEIS\.ORG\//, '').replace(/\/.*$/, '');
if (!/^A\d+$/.test(cleaned)) throw new Error(`"${id}" is not a valid A-number (expected A + digits, e.g. A000045)`);

Type guard

function isAnumber(v) { const s = String(v ?? '').trim().toUpperCase(); return /^A\d+$/.test(s.replace(/^HTTPS?:\/\/(?:WWW\.)?OEIS\.ORG\//, '').replace(/\/.*$/, '')); }

Try / catch

try { const sid = requireSequenceId(input); } catch (e) { console.error(e.message); console.error(e.details ?? ''); process.exitCode = 1; }

Prevention

When it happens

Trigger: Passing a malformed id such as 'B000045', 'A45' (too few digits if the pattern requires 6), 'Fibonacci', or a URL on a different domain (e.g. https://example.com/A000045).

Common situations: Typing the sequence name instead of its A-number, misremembering the prefix letter, or pasting a URL from a search result that is not oeis.org.

Related errors


AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29). Data as JSON: /api/errors/1e08081c46902606. Report an issue: GitHub.