jackwener/OpenCLI · error · ArgumentError

archive wayback timestamp must be YYYY[MM[DD[hh[mm[ss]]]]] o

Error message

archive wayback timestamp must be YYYY[MM[DD[hh[mm[ss]]]]] or an ISO date

What it means

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.

Source

Thrown at clis/archive/wayback.js:14

// archive wayback: Wayback Machine closest-snapshot lookup for a URL.
import { cli, Strategy } from '@jackwener/opencli/registry';
import {
    ArgumentError,
    CommandExecutionError,
    EmptyResultError,
} from '@jackwener/opencli/errors';

function normalizeTimestamp(raw) {
    // Accept YYYY, YYYYMM, YYYYMMDD, YYYYMMDDhh, YYYYMMDDhhmm, YYYYMMDDhhmmss,
    // YYYY-MM-DD, or YYYY-MM-DDThh:mm:ss. Strip non-digits and validate length.
    const digits = String(raw).replace(/[^0-9]/g, '');
    if (!/^\d{4,14}$/.test(digits) || digits.length % 2 !== 0 && digits.length !== 4) {
        throw new ArgumentError('archive wayback timestamp must be YYYY[MM[DD[hh[mm[ss]]]]] or an ISO date');
    }
    return digits;
}

cli({
    site: 'archive',
    name: 'wayback',
    access: 'read',
    description: 'Look up the closest Wayback Machine snapshot for a URL.',
    domain: 'archive.org',
    strategy: Strategy.PUBLIC,
    browser: false,
    args: [
        { name: 'url', positional: true, required: true, help: 'URL to look up (with or without scheme).' },
        { name: 'timestamp', type: 'string', required: false, help: 'Target timestamp (YYYY[MM[DD[hh[mm[ss]]]]] or ISO date). Defaults to most recent snapshot.' },
    ],
    columns: ['original_url', 'requested_timestamp', 'snapshot_timestamp', 'snapshot_url', 'status'],
    func: async (args) => {

View on GitHub (pinned to 49907e53dc)

Solutions

  1. Supply a valid precision: `2024`, `20240101`, or ISO `2024-01-01` / `2024-01-01T12:30:00`.
  2. Convert epoch timestamps to `YYYYMMDDhhmmss` form before passing.
  3. Omit `--timestamp` entirely to get the closest/most recent snapshot.
  4. Quote ISO timestamps with spaces/colons properly in your shell (`--timestamp "2024-01-01T12:00:00"`).

Example fix

// before
await exec('opencli archive wayback example.com --timestamp 2024-1');
// after
await exec('opencli archive wayback example.com --timestamp 2024-01');
Defensive patterns

Strategy: validation

Validate before calling

function isValidWaybackTimestamp(raw) {
  const digits = String(raw).replace(/[^0-9]/g, '');
  return /^\d{4,14}$/.test(digits) && (digits.length % 2 === 0 || digits.length === 4);
}
// run before invoking: if (!isValidWaybackTimestamp(ts)) fix input;

Type guard

function isSupportedTimestampPrecision(raw) {
  const n = String(raw).replace(/[^0-9]/g, '').length;
  return n === 4 || [6, 8, 10, 12, 14].includes(n);
}

Try / catch

try {
  await exec(`opencli archive wayback example.com --timestamp ${ts}`);
} catch (e) {
  if (String(e.message).includes('timestamp must be')) {
    // ArgumentError before any request — fix the format and retry
  } else throw e;
}

Prevention

When it happens

Trigger: 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).

Common situations: 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.

Related errors


AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29). Data as JSON: /api/errors/3c969199e6afd27b. Report an issue: GitHub.