{"record":{"id":"546f9e94b84f8ccc","repo":"jackwener/OpenCLI","slug":"archive-wayback-url-cannot-be-empty","errorCode":null,"errorMessage":"archive wayback url cannot be empty","messagePattern":"archive wayback url cannot be empty","errorType":"validation","errorClass":"ArgumentError","httpStatus":null,"severity":"error","filePath":"clis/archive/wayback.js","lineNumber":35,"sourceCode":"}\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) => {\n        const target = String(args.url ?? '').trim();\n        if (!target) {\n            throw new ArgumentError(\n                'archive wayback url cannot be empty',\n                'Example: opencli archive wayback wikipedia.org',\n            );\n        }\n        const timestamp = args.timestamp ? normalizeTimestamp(args.timestamp) : '';\n\n        const apiUrl = new URL('https://archive.org/wayback/available');\n        apiUrl.searchParams.set('url', target);\n        if (timestamp) apiUrl.searchParams.set('timestamp', timestamp);\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                },\n            });","sourceCodeStart":17,"sourceCodeEnd":53,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/archive/wayback.js#L17-L53","documentation":"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.","triggerScenarios":"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`).","commonSituations":"Scripting with unset environment variables; copying examples that show a placeholder; forgetting the positional argument because other subcommands use named flags.","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."],"exampleFix":"// before: variable may be unset\nawait exec(`opencli archive wayback ${process.env.TARGET}`);\n// after: validate first\nif (!process.env.TARGET?.trim()) throw new Error('TARGET env var must be a URL');\nawait exec(`opencli archive wayback ${process.env.TARGET}`);","handlingStrategy":"validation","validationCode":"const target = String(process.argv[3] ?? '').trim();\nif (!target) throw new Error('usage: opencli archive wayback <url>');","typeGuard":"function isNonEmptyString(v) {\n  return typeof v === 'string' && v.trim().length > 0;\n}","tryCatchPattern":null,"preventionTips":["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"],"tags":["argument-validation","missing-argument","input-validation"],"backgroundTag":"missing-required-argument","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}