{"record":{"id":"1b39905b232265fd","repo":"jackwener/OpenCLI","slug":"invalid-listid-json-stringify-kwargs-listid-1b3990","errorCode":null,"errorMessage":"Invalid listId: ${JSON.stringify(kwargs.listId)}. Expected numeric ID.","messagePattern":"Invalid listId: (.+?)\\. Expected numeric ID\\.","errorType":"validation","errorClass":"ArgumentError","httpStatus":null,"severity":"error","filePath":"clis/twitter/list-delete.js","lineNumber":88,"sourceCode":"\ncli({\n    site: 'twitter',\n    name: 'list-delete',\n    access: 'write',\n    description: 'Delete a Twitter/X list you own after explicit confirmation',\n    domain: 'x.com',\n    strategy: Strategy.UI,\n    browser: true,\n    args: [\n        { name: 'listId', positional: true, type: 'string', required: true, help: 'Numeric ID of the list you own (e.g. from `opencli twitter lists`)' },\n        { name: 'confirm', type: 'boolean', default: false, help: 'Required. Set --confirm true to delete the list.' },\n        { name: 'timeout', type: 'int', default: 300, help: 'Max seconds for the overall delete command (default: 300)' },\n    ],\n    columns: ['listId', 'name', 'members', 'status', 'message'],\n    func: async (page, kwargs) => {\n        const listId = String(kwargs.listId || '').trim();\n        if (!listId || !/^\\d+$/.test(listId)) {\n            throw new ArgumentError(`Invalid listId: ${JSON.stringify(kwargs.listId)}. Expected numeric ID.`, 'Example: opencli twitter list-delete 123456789 --confirm true');\n        }\n        if (!normalizeConfirm(kwargs.confirm)) {\n            throw new ArgumentError('Refusing to delete list without --confirm true', 'Example: opencli twitter list-delete 123456789 --confirm true');\n        }\n\n        await page.goto('https://x.com');\n        await page.wait(3);\n        const cookies = await page.getCookies({ url: 'https://x.com' });\n        const ct0 = cookies.find((c) => c.name === 'ct0')?.value || null;\n        if (!ct0) throw new AuthRequiredError('x.com', 'Not logged into x.com (no ct0 cookie)');\n\n        const headers = JSON.stringify({\n            'Authorization': `Bearer ${decodeURIComponent(TWITTER_BEARER_TOKEN)}`,\n            'X-Csrf-Token': ct0,\n            'X-Twitter-Auth-Type': 'OAuth2Session',\n            'X-Twitter-Active-User': 'yes',\n        });\n","sourceCodeStart":70,"sourceCodeEnd":106,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/twitter/list-delete.js#L70-L106","documentation":"The list-delete command requires listId to be a non-empty string of digits (Twitter list IDs are numeric). ArgumentError is thrown when listId is missing or contains non-numeric characters, before any network calls are made. This is a fail-fast input validation with a usage example attached.","triggerScenarios":"`twitter list-delete` called with an empty/undefined listId, a list slug or name instead of the numeric ID, or an ID containing whitespace/letters (e.g. 'abc', 'MyList', '').","commonSituations":"Passing the list's human-readable name or URL slug instead of its numeric ID; copy-pasting a URL fragment like 'i/lists/12345'; forgetting the positional argument entirely.","solutions":["Pass the numeric list ID, e.g. `opencli twitter list-delete 123456789 --confirm true`","If you only know the list name, run `twitter list-manage`/list-list to look up its numeric id first","Strip surrounding whitespace or URL prefixes from the ID before passing it","Quote the argument in shells where it might be mangled"],"exampleFix":"// before\nopencli twitter list-delete \"MyList\" --confirm true\n// after\nopencli twitter list-delete 123456789 --confirm true","handlingStrategy":"validation","validationCode":"function isValidListId(v) {\n  return typeof v === 'string' && /^\\d+$/.test(v.trim());\n}\nif (!isValidListId(process.argv[3])) throw new Error('listId must be numeric');","typeGuard":"function isNumericListId(v) {\n  return typeof v === 'string' && /^\\d+$/.test(v);\n}","tryCatchPattern":"try {\n  await page.func({ listId: args.listId, confirm: 'true' });\n} catch (e) {\n  if (e instanceof ArgumentError && /Invalid listId/.test(e.message)) {\n    console.error('Usage: opencli twitter list-delete <numeric-id> --confirm true');\n  } else throw e;\n}","preventionTips":["Look up numeric IDs via list-manage instead of guessing from names","Trim and strip URL prefixes from pasted IDs","Validate arguments in wrapper scripts before invoking the CLI"],"tags":["argument-validation","input-error","cli"],"backgroundTag":"invalid-argument","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}