{"record":{"id":"4e116fdbff8b91fc","repo":"jackwener/OpenCLI","slug":"archive-snapshots-url-cannot-be-empty","errorCode":null,"errorMessage":"archive snapshots url cannot be empty","messagePattern":"archive snapshots url cannot be empty","errorType":"validation","errorClass":"ArgumentError","httpStatus":null,"severity":"error","filePath":"clis/archive/snapshots.js","lineNumber":40,"sourceCode":"cli({\n    site: 'archive',\n    name: 'snapshots',\n    access: 'read',\n    description: 'List Wayback Machine snapshots over time for a URL via the CDX API.',\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: 'from', type: 'string', required: false, help: 'Earliest year/timestamp (YYYY[MM[DD[hh[mm[ss]]]]])' },\n        { name: 'to', type: 'string', required: false, help: 'Latest year/timestamp (YYYY[MM[DD[hh[mm[ss]]]]])' },\n        { name: 'limit', type: 'int', default: 20, help: 'Max snapshots to return (max 1000).' },\n    ],\n    columns: ['timestamp', 'snapshot_url', 'status', 'mimetype', 'original_url'],\n    func: async (args) => {\n        const target = String(args.url ?? '').trim();\n        if (!target) {\n            throw new ArgumentError(\n                'archive snapshots url cannot be empty',\n                'Example: opencli archive snapshots wikipedia.org',\n            );\n        }\n        const limit = Number(args.limit ?? 20);\n        if (!Number.isInteger(limit) || limit <= 0) {\n            throw new ArgumentError('archive snapshots limit must be a positive integer');\n        }\n        if (limit > 1000) {\n            throw new ArgumentError('archive snapshots limit must be <= 1000');\n        }\n        for (const key of ['from', 'to']) {\n            const v = args[key];\n            if (v != null && !/^\\d{4,14}$/.test(String(v))) {\n                throw new ArgumentError(`archive snapshots ${key} must be a digit-only timestamp (YYYY[MM[DD[hh[mm[ss]]]]])`);\n            }\n        }\n","sourceCodeStart":22,"sourceCodeEnd":58,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/archive/snapshots.js#L22-L58","documentation":"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.","triggerScenarios":"Running `opencli archive snapshots` with no url argument, or with an empty/whitespace string (\"\" or \"  \").","commonSituations":"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.","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."],"exampleFix":"// before (shell)\nURL=\"\"\nopencli archive snapshots \"$URL\"\n// after\nURL=\"wikipedia.org\"\nopencli archive snapshots \"$URL\"","handlingStrategy":"validation","validationCode":"// shell\nif [ -z \"${URL// /}\" ]; then echo \"url is required, e.g.: opencli archive snapshots wikipedia.org\" >&2; exit 1; fi\nopencli archive snapshots \"$URL\"\n// node\nif (!url || !String(url).trim()) throw new Error('url is required');","typeGuard":"function isValidTarget(v) {\n  return typeof v === 'string' && v.trim().length > 0;\n}","tryCatchPattern":"try {\n  await run(['archive', 'snapshots', url]);\n} catch (e) {\n  if (/url cannot be empty/.test(e.message)) {\n    console.error('usage: opencli archive snapshots <site>');\n    process.exitCode = 2;\n  } else throw e;\n}","preventionTips":["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."],"tags":["argument-validation","cli-input","user-input","archive-org"],"backgroundTag":"missing-required-argument","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}