jackwener/OpenCLI · error · ArgumentError
未知的 action: ${action}
Error message
未知的 action: ${action} What it means
ArgumentError thrown by the douyin hashtag command when the action argument is not one of the supported values (search/suggest/hot). The command dispatches on action and this is the terminal else branch.
Source
Thrown at clis/douyin/hashtag.js:118
if (allSentences !== undefined && allSentences !== null && !Array.isArray(allSentences)) {
throw new CommandExecutionError('douyin hashtag hot: API returned malformed "all_sentences"');
}
const items = Array.isArray(hotspotList)
? hotspotList
: Array.isArray(allSentences)
? allSentences.map(h => ({
sentence: h?.word ?? '',
hot_value: h?.hot_value,
sentence_id: h?.sentence_id ?? '',
}))
: [];
return items.slice(0, kwargs.limit).map(h => ({
name: h?.sentence ?? '',
id: h && 'sentence_id' in h ? h.sentence_id : '',
view_count: h?.hot_value ?? 0,
}));
}
throw new ArgumentError(`未知的 action: ${action}`);
},
});
View on GitHub (pinned to 49907e53dc)
Solutions
- Use a supported action: search, suggest, or hot.
- Run the command with --help to list valid actions.
- Fix the action name in your script/alias.
Example fix
// before opencli douyin hashtag trending --keyword foo // after opencli douyin hashtag hot --keyword foo
Defensive patterns
Strategy: validation
Validate before calling
const VALID_ACTIONS = ['search', 'suggest', 'hot'];
if (!VALID_ACTIONS.includes(action)) {
throw new Error(`invalid action "${action}"; expected one of ${VALID_ACTIONS.join(', ')}`);
} Try / catch
try {
await hashtag({ action, ...rest });
} catch (e) {
if (String(e.message).startsWith('未知的 action')) {
console.error(`"${action}" is not valid; use search | suggest | hot`);
process.exitCode = 2;
} else throw e;
} Prevention
- Validate action names in wrapper scripts before invoking the CLI.
- Use --help to discover supported actions instead of guessing.
- Centralize action names as constants in automation code.
When it happens
Trigger: Invoking the hashtag command with any action string other than the registered ones, e.g. a typo like `hashtag serach` or `hashtag trending` (clis/douyin/hashtag.js:118).
Common situations: Typos in CLI usage; scripts written against an imagined action name; docs from an older/newer version listing different actions.
Understand the failure class
Background: "Must be a positive integer", "Invalid value", "Unsupported": the invalid-argument-value error family, when a library rejects the value you pass — this error's family across 35 libraries.
Related errors
- twitter download requires either <username> or --tweet-url
- <train-no> "${trainNo}" does not look like a 12306 internal
- --from station must not be empty
- --to station must not be empty
- --seat-types must contain only 12306 seat letters/digits (A-
AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29).
Data as JSON: /api/errors/2e80b00d7a0db039.
Report an issue: GitHub.