{"record":{"id":"3c969199e6afd27b","repo":"jackwener/OpenCLI","slug":"archive-wayback-timestamp-must-be-yyyy-mm-dd-hh-mm","errorCode":null,"errorMessage":"archive wayback timestamp must be YYYY[MM[DD[hh[mm[ss]]]]] or an ISO date","messagePattern":"archive wayback timestamp must be YYYY\\[MM\\[DD\\[hh\\[mm\\[ss\\]\\]\\]\\]\\] or an ISO date","errorType":"validation","errorClass":"ArgumentError","httpStatus":null,"severity":"error","filePath":"clis/archive/wayback.js","lineNumber":14,"sourceCode":"// archive wayback: Wayback Machine closest-snapshot lookup for a URL.\nimport { cli, Strategy } from '@jackwener/opencli/registry';\nimport {\n    ArgumentError,\n    CommandExecutionError,\n    EmptyResultError,\n} from '@jackwener/opencli/errors';\n\nfunction normalizeTimestamp(raw) {\n    // Accept YYYY, YYYYMM, YYYYMMDD, YYYYMMDDhh, YYYYMMDDhhmm, YYYYMMDDhhmmss,\n    // YYYY-MM-DD, or YYYY-MM-DDThh:mm:ss. Strip non-digits and validate length.\n    const digits = String(raw).replace(/[^0-9]/g, '');\n    if (!/^\\d{4,14}$/.test(digits) || digits.length % 2 !== 0 && digits.length !== 4) {\n        throw new ArgumentError('archive wayback timestamp must be YYYY[MM[DD[hh[mm[ss]]]]] or an ISO date');\n    }\n    return digits;\n}\n\ncli({\n    site: 'archive',\n    name: 'wayback',\n    access: 'read',\n    description: 'Look up the closest Wayback Machine snapshot for a URL.',\n    domain: 'archive.org',\n    strategy: Strategy.PUBLIC,\n    browser: false,\n    args: [\n        { name: 'url', positional: true, required: true, help: 'URL to look up (with or without scheme).' },\n        { name: 'timestamp', type: 'string', required: false, help: 'Target timestamp (YYYY[MM[DD[hh[mm[ss]]]]] or ISO date). Defaults to most recent snapshot.' },\n    ],\n    columns: ['original_url', 'requested_timestamp', 'snapshot_timestamp', 'snapshot_url', 'status'],\n    func: async (args) => {","sourceCodeStart":1,"sourceCodeEnd":32,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/archive/wayback.js#L1-L32","documentation":"The `archive wayback` command's `timestamp` argument is normalized by `normalizeTimestamp`, which strips all non-digits and requires the result to be 4–14 digits forming a valid precision (even length, or exactly 4 for a year-only value). This ArgumentError is thrown when the value cannot be interpreted as a Wayback timestamp (YYYY[MM[DD[hh[mm[ss]]]]]) or ISO date. It is raised before any network call.","triggerScenarios":"Passing `--timestamp` values like `2024-1` (odd digit count, not 4), `24` (fewer than 4 digits), `not-a-date`, or a malformed ISO date such as `2024-13-99T00:00` whose digits form an invalid length; also numeric timestamps in epoch seconds (e.g. `1722000000` — 10 digits, even length... but arbitrary epoch values that don't map to calendar precision still pass the regex check here; main failures are wrong digit counts).","commonSituations":"Users typing human dates like `Jan 2024`, epoch/unix timestamps, or partially typed dates like `20240`; shell quoting issues splitting `2024-01-01T00:00:00`; passing a full URL or year range where a single timestamp is expected.","solutions":["Supply a valid precision: `2024`, `20240101`, or ISO `2024-01-01` / `2024-01-01T12:30:00`.","Convert epoch timestamps to `YYYYMMDDhhmmss` form before passing.","Omit `--timestamp` entirely to get the closest/most recent snapshot.","Quote ISO timestamps with spaces/colons properly in your shell (`--timestamp \"2024-01-01T12:00:00\"`)."],"exampleFix":"// before\nawait exec('opencli archive wayback example.com --timestamp 2024-1');\n// after\nawait exec('opencli archive wayback example.com --timestamp 2024-01');","handlingStrategy":"validation","validationCode":"function isValidWaybackTimestamp(raw) {\n  const digits = String(raw).replace(/[^0-9]/g, '');\n  return /^\\d{4,14}$/.test(digits) && (digits.length % 2 === 0 || digits.length === 4);\n}\n// run before invoking: if (!isValidWaybackTimestamp(ts)) fix input;\n","typeGuard":"function isSupportedTimestampPrecision(raw) {\n  const n = String(raw).replace(/[^0-9]/g, '').length;\n  return n === 4 || [6, 8, 10, 12, 14].includes(n);\n}","tryCatchPattern":"try {\n  await exec(`opencli archive wayback example.com --timestamp ${ts}`);\n} catch (e) {\n  if (String(e.message).includes('timestamp must be')) {\n    // ArgumentError before any request — fix the format and retry\n  } else throw e;\n}","preventionTips":["Use ISO dates (2024-01-01) or fixed-precision digit strings","Never pass epoch seconds directly — convert to YYYYMMDDhhmmss first","Quote ISO timestamps with colons in your shell","Omit --timestamp when you just want the latest snapshot"],"tags":["argument-validation","timestamp","input-validation"],"backgroundTag":"invalid-argument-format","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}