{"record":{"id":"1e08081c46902606","repo":"jackwener/OpenCLI","slug":"oeis-sequence-id-value-is-not-a-valid-a-numbe","errorCode":null,"errorMessage":"oeis sequence id \"${value}\" is not a valid A-number","messagePattern":"oeis sequence id \"(.+?)\" is not a valid A-number","errorType":"validation","errorClass":"ArgumentError","httpStatus":null,"severity":"error","filePath":"clis/oeis/utils.js","lineNumber":38,"sourceCode":"export 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(\n            `${label} request failed: ${err?.message ?? err}`,\n            'Check that oeis.org is reachable from this network.',\n        );\n    }","sourceCodeStart":20,"sourceCodeEnd":56,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/oeis/utils.js#L20-L56","documentation":"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.","triggerScenarios":"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).","commonSituations":"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.","solutions":["Use the canonical A-number format: 'A' + 6 digits, e.g. A000045.","Look up the sequence on oeis.org and copy its id.","If pasting a URL, ensure it is an https?://(www.)oeis.org/... link."],"exampleFix":"// before\noeis id Fibonacci\n// after\noeis id A000045","handlingStrategy":"validation","validationCode":"const cleaned = String(id ?? '').trim().toUpperCase().replace(/^HTTPS?:\\/\\/(?:WWW\\.)?OEIS\\.ORG\\//, '').replace(/\\/.*$/, '');\nif (!/^A\\d+$/.test(cleaned)) throw new Error(`\"${id}\" is not a valid A-number (expected A + digits, e.g. A000045)`);","typeGuard":"function isAnumber(v) { const s = String(v ?? '').trim().toUpperCase(); return /^A\\d+$/.test(s.replace(/^HTTPS?:\\/\\/(?:WWW\\.)?OEIS\\.ORG\\//, '').replace(/\\/.*$/, '')); }","tryCatchPattern":"try { const sid = requireSequenceId(input); } catch (e) { console.error(e.message); console.error(e.details ?? ''); process.exitCode = 1; }","preventionTips":["Always copy ids in the canonical A000000 form from oeis.org.","Normalize input (trim/uppercase/strip URL) before validating.","Validate with the same regex the library uses: /^A\\d+$/."],"tags":["validation","format","input"],"backgroundTag":"invalid-format","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}