jackwener/OpenCLI · error · ArgumentError
twitter mute-word keyword cannot be empty
Error message
twitter mute-word keyword cannot be empty
What it means
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.
Source
Thrown at clis/twitter/mute-word.js:7
import { ArgumentError, CommandExecutionError, TimeoutError } from '@jackwener/opencli/errors';
import { cli, Strategy } from '@jackwener/opencli/registry';
function parseKeyword(value) {
const keyword = String(value ?? '').trim();
if (!keyword) {
throw new ArgumentError('twitter mute-word keyword cannot be empty');
}
return keyword;
}
cli({
site: 'twitter',
name: 'mute-word',
access: 'write',
description: 'Add a muted word or phrase on Twitter/X',
domain: 'x.com',
strategy: Strategy.UI,
browser: true,
args: [
{ name: 'keyword', type: 'string', positional: true, required: true, help: 'Word or phrase to mute' },
],
columns: ['keyword', 'status', 'message'],
func: async (page, kwargs) => {
if (!page) {View on GitHub (pinned to 49907e53dc)
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.
Example fix
// before
const kw = process.env.MUTE_KEYWORD;
await run(['twitter', 'mute-word', kw]);
// after
const kw = (process.env.MUTE_KEYWORD || '').trim();
if (!kw) throw new Error('MUTE_KEYWORD is empty; refusing to run twitter mute-word');
await run(['twitter', 'mute-word', kw]); Defensive patterns
Strategy: validation
Validate before calling
const kw = String(rawKeyword ?? '').trim();
if (!kw) throw new Error('Keyword required: pass a non-empty quoted positional argument'); Type guard
function hasKeyword(v) {
return typeof v === 'string' && v.trim().length > 0;
} Try / catch
try {
await run(['twitter', 'mute-word', kw]);
} catch (err) {
if (err.name === 'ArgumentError') {
console.error('Usage: twitter mute-word "<keyword>"');
process.exitCode = 2;
} else throw err;
} Prevention
- 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
When it happens
Trigger: 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.
Common situations: 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.
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
- ${label} cannot be empty
- Instagram note content cannot be empty.
- prompt cannot be empty
- packagist ${label} cannot be empty
- No fids provided
AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29).
Data as JSON: /api/errors/28642eb94af1feac.
Report an issue: GitHub.