{"record":{"id":"7df286bd54b64bec","repo":"jackwener/OpenCLI","slug":"archive-snapshots-key-must-be-a-digit-only-time","errorCode":null,"errorMessage":"archive snapshots ${key} must be a digit-only timestamp (YYYY[MM[DD[hh[mm[ss]]]]])","messagePattern":"archive snapshots (.+?) must be a digit-only timestamp \\(YYYY\\[MM\\[DD\\[hh\\[mm\\[ss\\]\\]\\]\\]\\]\\)","errorType":"validation","errorClass":"ArgumentError","httpStatus":null,"severity":"error","filePath":"clis/archive/snapshots.js","lineNumber":55,"sourceCode":"    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 {\n            resp = await fetch(apiUrl, {\n                headers: {\n                    'Accept': 'application/json',\n                    'User-Agent': 'opencli/1.0 (+https://github.com/jackwener/opencli)',\n                },","sourceCodeStart":37,"sourceCodeEnd":73,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/archive/snapshots.js#L37-L73","documentation":"ArgumentError thrown when the optional `from` or `to` arguments are provided but are not digit-only strings of length 4–14, the Wayback timestamp format YYYY[MM[DD[hh[mm[ss]]]]]. The regex ^\\d{4,14}$ enforces both character set and length; separators like dashes or colons are rejected.","triggerScenarios":"Passing --from or --to values like '2023-01-01', '2023/01/01', '2023-01-01T00:00:00', an ISO 8601 string, a 3-digit year, or a >14-digit value.","commonSituations":"Copy-pasting ISO dates from logs; using human-readable date formats; shell variables carrying formatted dates from `date` command output.","solutions":["Convert to Wayback compact format: '2023-01-01' becomes 20230101.","Use plain digits only, 4–14 chars: 2023, 202301, 20230101, up to 20230101120000.","Generate the format in scripts: date -u +%Y%m%d (GNU date) for a today stamp.","Omit from/to if a full-range query is acceptable."],"exampleFix":"// before\nopencli archive snapshots example.org --from 2023-01-01 --to 2023-12-31\n// after\nopencli archive snapshots example.org --from 20230101 --to 20231231","handlingStrategy":"validation","validationCode":"// node\nconst WAYBACK_TS = /^\\d{4,14}$/;\nfunction toWaybackTs(iso) {\n  return iso.replaceAll(/[-:T]/g, '').slice(0, 14);\n}\nif (from && !WAYBACK_TS.test(from)) from = toWaybackTs(from);","typeGuard":"function isWaybackTimestamp(v) {\n  return typeof v === 'string' && /^\\d{4,14}$/.test(v);\n}","tryCatchPattern":"try {\n  await run(['archive', 'snapshots', url, '--from', from, '--to', to]);\n} catch (e) {\n  if (/must be a digit-only timestamp/.test(e.message)) {\n    const key = /snapshots (\\w+)/.exec(e.message)?.[1];\n    console.error(`reformat ${key} as digits only, e.g. 20230101`);\n  } else throw e;\n}","preventionTips":["Always convert ISO dates with date -u +%Y%m%d or equivalent before passing.","Never pass dashed/slash-separated dates to this CLI.","Keep timestamps digit-only, 4 to 14 characters long."],"tags":["argument-validation","cli-input","date-format","archive-org"],"backgroundTag":"invalid-date-format","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}