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

  1. Use a supported action: search, suggest, or hot.
  2. Run the command with --help to list valid actions.
  3. 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

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


AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29). Data as JSON: /api/errors/2e80b00d7a0db039. Report an issue: GitHub.