{"record":{"id":"28642eb94af1feac","repo":"jackwener/OpenCLI","slug":"twitter-mute-word-keyword-cannot-be-empty","errorCode":null,"errorMessage":"twitter mute-word keyword cannot be empty","messagePattern":"twitter mute-word keyword cannot be empty","errorType":"validation","errorClass":"ArgumentError","httpStatus":null,"severity":"error","filePath":"clis/twitter/mute-word.js","lineNumber":7,"sourceCode":"import { ArgumentError, CommandExecutionError, TimeoutError } from '@jackwener/opencli/errors';\nimport { cli, Strategy } from '@jackwener/opencli/registry';\n\nfunction parseKeyword(value) {\n    const keyword = String(value ?? '').trim();\n    if (!keyword) {\n        throw new ArgumentError('twitter mute-word keyword cannot be empty');\n    }\n    return keyword;\n}\n\ncli({\n    site: 'twitter',\n    name: 'mute-word',\n    access: 'write',\n    description: 'Add a muted word or phrase on Twitter/X',\n    domain: 'x.com',\n    strategy: Strategy.UI,\n    browser: true,\n    args: [\n        { name: 'keyword', type: 'string', positional: true, required: true, help: 'Word or phrase to mute' },\n    ],\n    columns: ['keyword', 'status', 'message'],\n    func: async (page, kwargs) => {\n        if (!page) {","sourceCodeStart":1,"sourceCodeEnd":25,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/twitter/mute-word.js#L1-L25","documentation":"ArgumentError thrown by parseKeyword when the positional 'keyword' argument for the twitter mute-word command is missing, empty, or whitespace-only after trimming. The CLI requires a non-empty word or phrase to add as a muted keyword on X; it fails fast at argument parsing rather than opening a browser session.","triggerScenarios":"Running `... twitter mute-word` with no positional argument, an empty string (''), or a value consisting only of spaces/tabs (String(value ?? '').trim() yields ''). Also triggered when a quoting mistake makes the shell drop the argument.","commonSituations":"Shell quoting errors (unquoted phrases get split or dropped), scripts passing empty variables (KEYWORD=\"\"), CI pipelines with unset environment variables interpolated into the command line.","solutions":["Pass the keyword as a quoted positional argument: twitter mute-word \"spoiler phrase\".","Check that the shell variable feeding the argument is non-empty before invoking the command.","Fix quoting so multi-word phrases survive as a single argument.","For empty input in scripts, guard with a check and skip the command instead of calling it."],"exampleFix":"// before\nconst kw = process.env.MUTE_KEYWORD;\nawait run(['twitter', 'mute-word', kw]);\n// after\nconst kw = (process.env.MUTE_KEYWORD || '').trim();\nif (!kw) throw new Error('MUTE_KEYWORD is empty; refusing to run twitter mute-word');\nawait run(['twitter', 'mute-word', kw]);","handlingStrategy":"validation","validationCode":"const kw = String(rawKeyword ?? '').trim();\nif (!kw) throw new Error('Keyword required: pass a non-empty quoted positional argument');","typeGuard":"function hasKeyword(v) {\n  return typeof v === 'string' && v.trim().length > 0;\n}","tryCatchPattern":"try {\n  await run(['twitter', 'mute-word', kw]);\n} catch (err) {\n  if (err.name === 'ArgumentError') {\n    console.error('Usage: twitter mute-word \"<keyword>\"');\n    process.exitCode = 2;\n  } else throw err;\n}","preventionTips":["Always quote multi-word keywords in the shell","Validate shell/env variables are non-empty before interpolating into commands","Add a usage check in wrapper scripts before invoking the CLI"],"tags":["argument-validation","cli","twitter","empty-input"],"backgroundTag":"missing-required-argument","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}