{"record":{"id":"dc4421e818777980","repo":"jackwener/OpenCLI","slug":"rfc-number-must-be-999999","errorCode":null,"errorMessage":"rfc number must be <= 999999","messagePattern":"rfc number must be <= 999999","errorType":"validation","errorClass":"ArgumentError","httpStatus":null,"severity":"error","filePath":"clis/rfc/utils.js","lineNumber":29,"sourceCode":"export function requireRfcNumber(value) {\n    const raw = value;\n    if (raw == null || String(raw).trim() === '') {\n        throw new ArgumentError(\n            'rfc number is required (e.g. 9000, 791, 2616)',\n            'Pass the integer RFC number; do not include the \"rfc\" prefix.',\n        );\n    }\n    // Accept \"9000\" or 9000 or \"rfc9000\" as a courtesy.\n    const s = String(raw).trim().toLowerCase().replace(/^rfc/, '');\n    const n = Number.parseInt(s, 10);\n    if (!Number.isInteger(n) || n <= 0 || String(n) !== s) {\n        throw new ArgumentError(\n            `rfc number \"${value}\" is not a valid RFC number`,\n            'Pass a positive integer (e.g. 9000, 791, 2616).',\n        );\n    }\n    if (n > 999999) {\n        throw new ArgumentError('rfc number must be <= 999999');\n    }\n    return n;\n}\n\nexport async function rfcFetch(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 datatracker.ietf.org is reachable from this network.',\n        );\n    }\n    if (resp.status === 404) {\n        throw new EmptyResultError(label, `IETF datatracker returned 404 for ${url}.`);\n    }","sourceCodeStart":11,"sourceCodeEnd":47,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/rfc/utils.js#L11-L47","documentation":"requireRfcNumber caps RFC numbers at 999999 to guard against absurd inputs and malformed requests to the datatracker API. Values above this limit throw ArgumentError immediately, before any network call.","triggerScenarios":"Passing --number with an integer > 999999, e.g. --number 1000000 or a padded/concatenated value like 'rfc1234567890'.","commonSituations":"Users concatenating numbers by mistake, testing with sentinel values like 99999999, or confusing RFC numbers with other document IDs (drafts, DOIs).","solutions":["Use an RFC number of 999999 or less — real RFCs are far below this.","Remove duplicated digits or concatenated values from the input.","Confirm the number against the RFC index if unsure.","Catch ArgumentError to re-prompt with the documented bound."],"exampleFix":"// before\nrfc rfc --number 1234567\n// after\nrfc rfc --number 9000","handlingStrategy":"validation","validationCode":"function rfcNumberWithinBounds(v, max = 999999) {\n  const n = Number(v);\n  return Number.isInteger(n) && n > 0 && n <= max;\n}\nif (!rfcNumberWithinBounds(input)) input = 9000;","typeGuard":"const rfcInBounds = (v) => { const n = Number(v); return Number.isInteger(n) && n > 0 && n <= 999999; };","tryCatchPattern":"try {\n  const n = requireRfcNumber(input);\n} catch (err) {\n  if (err instanceof ArgumentError && /<= 999999/.test(err.message)) {\n    console.error('RFC number too large; use the real RFC number.');\n  } else throw err;\n}","preventionTips":["Bound-check user input in scripts before invoking the CLI.","Avoid concatenating digits when building numbers from IDs.","Only pass genuine RFC numbers — real ones are well under 10000 today.","Log the offending value to spot systematic input corruption."],"tags":["cli","argument-validation","range-check"],"backgroundTag":"value-out-of-range","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}