jackwener/OpenCLI · error · ArgumentError
archive wayback url cannot be empty
Error message
archive wayback url cannot be empty
What it means
The `archive wayback` command requires a positional `url` argument identifying the site to look up. This ArgumentError is thrown when the argument is missing or resolves to an empty/whitespace-only string, before any network request is made.
Source
Thrown at clis/archive/wayback.js:35
}
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) => {
const target = String(args.url ?? '').trim();
if (!target) {
throw new ArgumentError(
'archive wayback url cannot be empty',
'Example: opencli archive wayback wikipedia.org',
);
}
const timestamp = args.timestamp ? normalizeTimestamp(args.timestamp) : '';
const apiUrl = new URL('https://archive.org/wayback/available');
apiUrl.searchParams.set('url', target);
if (timestamp) apiUrl.searchParams.set('timestamp', timestamp);
let resp;
try {
resp = await fetch(apiUrl, {
headers: {
'Accept': 'application/json',
'User-Agent': 'opencli/1.0 (+https://github.com/jackwener/opencli)',
},
});View on GitHub (pinned to 49907e53dc)
Solutions
- Pass the target as a positional argument: `opencli archive wayback wikipedia.org`.
- In scripts, guard that the URL variable is non-empty before invoking.
- Check shell quoting/interpolation — ensure `$VAR` actually expands to the intended URL.
Example fix
// before: variable may be unset
await exec(`opencli archive wayback ${process.env.TARGET}`);
// after: validate first
if (!process.env.TARGET?.trim()) throw new Error('TARGET env var must be a URL');
await exec(`opencli archive wayback ${process.env.TARGET}`); Defensive patterns
Strategy: validation
Validate before calling
const target = String(process.argv[3] ?? '').trim();
if (!target) throw new Error('usage: opencli archive wayback <url>'); Type guard
function isNonEmptyString(v) {
return typeof v === 'string' && v.trim().length > 0;
} Prevention
- Always pass the URL as a positional argument, not a flag
- Validate env vars are set before interpolating into commands
- Add usage assertions in scripts that shell out to the CLI
When it happens
Trigger: Running the command with no positional argument, passing only flags, or passing a value that is empty/whitespace (e.g. `--url " "` style quoting mistakes); shell interpolation expanding a variable to nothing (`opencli archive wayback $EMPTY_VAR`).
Common situations: Scripting with unset environment variables; copying examples that show a placeholder; forgetting the positional argument because other subcommands use named flags.
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
- designer is required (for example: halolab)
- shot is required (numeric id or dribbble.com/shots URL)
- query is required
- emoji required (a single unicode emoji)
- emoji required (the unicode emoji to remove)
AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29).
Data as JSON: /api/errors/546f9e94b84f8ccc.
Report an issue: GitHub.