jackwener/OpenCLI · error · ArgumentError
archive snapshots url cannot be empty
Error message
archive snapshots url cannot be empty
What it means
ArgumentError thrown up front by `opencli archive snapshots` when the `url` argument is missing, empty, or whitespace-only after trimming. It is pure client-side input validation — no network request is made — and the error message includes an example invocation to guide correct usage.
Source
Thrown at clis/archive/snapshots.js:40
cli({
site: 'archive',
name: 'snapshots',
access: 'read',
description: 'List Wayback Machine snapshots over time for a URL via the CDX API.',
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: 'from', type: 'string', required: false, help: 'Earliest year/timestamp (YYYY[MM[DD[hh[mm[ss]]]]])' },
{ name: 'to', type: 'string', required: false, help: 'Latest year/timestamp (YYYY[MM[DD[hh[mm[ss]]]]])' },
{ name: 'limit', type: 'int', default: 20, help: 'Max snapshots to return (max 1000).' },
],
columns: ['timestamp', 'snapshot_url', 'status', 'mimetype', 'original_url'],
func: async (args) => {
const target = String(args.url ?? '').trim();
if (!target) {
throw new ArgumentError(
'archive snapshots url cannot be empty',
'Example: opencli archive snapshots wikipedia.org',
);
}
const limit = Number(args.limit ?? 20);
if (!Number.isInteger(limit) || limit <= 0) {
throw new ArgumentError('archive snapshots limit must be a positive integer');
}
if (limit > 1000) {
throw new ArgumentError('archive snapshots limit must be <= 1000');
}
for (const key of ['from', 'to']) {
const v = args[key];
if (v != null && !/^\d{4,14}$/.test(String(v))) {
throw new ArgumentError(`archive snapshots ${key} must be a digit-only timestamp (YYYY[MM[DD[hh[mm[ss]]]]])`);
}
}
View on GitHub (pinned to 49907e53dc)
Solutions
- Pass the target site/domain as the url argument: opencli archive snapshots wikipedia.org
- In scripts, guard against unset variables: [ -n "$URL" ] || exit 1 before invoking the CLI.
- Check argument ordering — the url must be supplied to the `url` arg, not swallowed by a flag.
Example fix
// before (shell) URL="" opencli archive snapshots "$URL" // after URL="wikipedia.org" opencli archive snapshots "$URL"
Defensive patterns
Strategy: validation
Validate before calling
// shell
if [ -z "${URL// /}" ]; then echo "url is required, e.g.: opencli archive snapshots wikipedia.org" >&2; exit 1; fi
opencli archive snapshots "$URL"
// node
if (!url || !String(url).trim()) throw new Error('url is required'); Type guard
function isValidTarget(v) {
return typeof v === 'string' && v.trim().length > 0;
} Try / catch
try {
await run(['archive', 'snapshots', url]);
} catch (e) {
if (/url cannot be empty/.test(e.message)) {
console.error('usage: opencli archive snapshots <site>');
process.exitCode = 2;
} else throw e;
} Prevention
- Always quote shell variables to catch unset values early.
- Validate script inputs (non-empty url) before invoking the CLI.
- Never rely on positional args coming from possibly-empty variables without checks.
When it happens
Trigger: Running `opencli archive snapshots` with no url argument, or with an empty/whitespace string ("" or " ").
Common situations: Scripting the CLI with a variable that failed to expand (e.g. empty $URL in shell); forgetting the positional argument; passing an option in the wrong slot so url stays empty.
Understand the failure class
Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.
Related errors
- archive snapshots limit must be a positive integer
- archive snapshots limit must be <= 1000
- archive snapshots ${key} must be a digit-only timestamp (YYY
- --from and --to must differ (got ${fromCode})
- No items match "${query}" on archive.org.
AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29).
Data as JSON: /api/errors/4e116fdbff8b91fc.
Report an issue: GitHub.