{"record":{"id":"aaf71e525ad9afe5","repo":"jackwener/OpenCLI","slug":"archive-snapshots-limit-must-be-1000","errorCode":null,"errorMessage":"archive snapshots limit must be <= 1000","messagePattern":"archive snapshots limit must be <= 1000","errorType":"validation","errorClass":"ArgumentError","httpStatus":null,"severity":"error","filePath":"clis/archive/snapshots.js","lineNumber":50,"sourceCode":"        { name: 'from', type: 'string', required: false, help: 'Earliest year/timestamp (YYYY[MM[DD[hh[mm[ss]]]]])' },\n        { name: 'to', type: 'string', required: false, help: 'Latest year/timestamp (YYYY[MM[DD[hh[mm[ss]]]]])' },\n        { name: 'limit', type: 'int', default: 20, help: 'Max snapshots to return (max 1000).' },\n    ],\n    columns: ['timestamp', 'snapshot_url', 'status', 'mimetype', 'original_url'],\n    func: async (args) => {\n        const target = String(args.url ?? '').trim();\n        if (!target) {\n            throw new ArgumentError(\n                'archive snapshots url cannot be empty',\n                'Example: opencli archive snapshots wikipedia.org',\n            );\n        }\n        const limit = Number(args.limit ?? 20);\n        if (!Number.isInteger(limit) || limit <= 0) {\n            throw new ArgumentError('archive snapshots limit must be a positive integer');\n        }\n        if (limit > 1000) {\n            throw new ArgumentError('archive snapshots limit must be <= 1000');\n        }\n        for (const key of ['from', 'to']) {\n            const v = args[key];\n            if (v != null && !/^\\d{4,14}$/.test(String(v))) {\n                throw new ArgumentError(`archive snapshots ${key} must be a digit-only timestamp (YYYY[MM[DD[hh[mm[ss]]]]])`);\n            }\n        }\n\n        // Wayback CDX is served on HTTP only; the HTTPS endpoint returns 503.\n        const apiUrl = new URL('http://web.archive.org/cdx/search/cdx');\n        apiUrl.searchParams.set('url', target);\n        apiUrl.searchParams.set('output', 'json');\n        apiUrl.searchParams.set('limit', String(limit));\n        if (args.from) apiUrl.searchParams.set('from', String(args.from));\n        if (args.to) apiUrl.searchParams.set('to', String(args.to));\n\n        let resp;\n        try {","sourceCodeStart":32,"sourceCodeEnd":68,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/archive/snapshots.js#L32-L68","documentation":"ArgumentError thrown when the `limit` argument exceeds the library's hard maximum of 1000, which matches the Wayback CDX API's own per-page cap. This prevents users from requesting result counts the API cannot serve anyway.","triggerScenarios":"Running `opencli archive snapshots <url> --limit 1001` (or any larger value).","commonSituations":"Users wanting 'all snapshots' guessing a huge number; misunderstanding limit as unlimited when set very high.","solutions":["Cap the limit at 1000: opencli archive snapshots example.org --limit 1000","Paginate with CDX 'from'/'to' timestamp filters to cover more than 1000 snapshots in chunks.","Omit --limit to get the default 20."],"exampleFix":"// before\nopencli archive snapshots example.org --limit 5000\n// after\nopencli archive snapshots example.org --limit 1000","handlingStrategy":"validation","validationCode":"// Clamp before invoking\nconst clamped = Math.min(Math.max(1, Math.floor(Number(raw) || 20)), 1000);\n// node\nif (n > 1000) { n = 1000; console.warn('limit clamped to CDX max of 1000'); }","typeGuard":"function isWithinLimit(v, max = 1000) {\n  return Number.isInteger(v) && v > 0 && v <= max;\n}","tryCatchPattern":"try {\n  await run(['archive', 'snapshots', url, '--limit', String(limit)]);\n} catch (e) {\n  if (/limit must be <= 1000/.test(e.message)) {\n    await run(['archive', 'snapshots', url, '--limit', '1000']);\n  } else throw e;\n}","preventionTips":["Remember 1000 is the Wayback CDX per-request cap; clamp inputs.","For >1000 snapshots, chunk queries with from/to timestamps instead of raising the limit.","Document the cap wherever limit values are sourced."],"tags":["argument-validation","cli-input","limits","archive-org"],"backgroundTag":"invalid-argument-value","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}