jackwener/OpenCLI · error · ArgumentError
douyin hashtag suggest 需要 --cover <cover_uri>
Error message
douyin hashtag suggest 需要 --cover <cover_uri>
What it means
The `suggest` action recommends hashtags from an already-uploaded video cover URI and therefore requires --cover. validateHashtagArgs throws an ArgumentError (with guidance pointing keyword searches to the `search` action) when the cover value is empty after trimming.
Source
Thrown at clis/douyin/hashtag.js:37
}
function validateHashtagArgs(kwargs) {
const action = kwargs.action;
const limit = Number(kwargs.limit ?? 10);
if (!Number.isInteger(limit) || limit < 1) {
throw new ArgumentError(`--limit must be a positive integer, got ${JSON.stringify(kwargs.limit)}`);
}
if (action === 'search') {
const keyword = String(kwargs.keyword ?? '').trim();
if (!keyword) {
throw new ArgumentError('douyin hashtag search 需要 --keyword <关键词>', '示例: opencli douyin hashtag search --keyword 美食');
}
return;
}
if (action === 'suggest') {
const cover = String(kwargs.cover ?? '').trim();
if (!cover) {
throw new ArgumentError('douyin hashtag suggest 需要 --cover <cover_uri>', 'suggest 基于已上传的视频封面做 AI 推荐, 不是关键词搜索. 关键词搜索请用 `douyin hashtag search --keyword <词>`.');
}
}
}
cli({
site: 'douyin',
name: 'hashtag',
access: 'read',
description: '话题搜索 / AI推荐 / 热点词',
domain: 'creator.douyin.com',
strategy: Strategy.COOKIE,
args: [
{ name: 'action', required: true, positional: true, choices: ['search', 'suggest', 'hot'], help: 'search=关键词搜索 (--keyword 必填), suggest=AI推荐 (--cover 必填), hot=热点词 (--keyword 可选)' },
{ name: 'keyword', default: '', help: '搜索关键词. search 必填; hot 可选; suggest 不使用 (传 --cover)' },
{ name: 'cover', default: '', help: '封面 URI (cover_uri). suggest 必填; 其它 action 不使用' },
{ name: 'limit', type: 'int', default: 10 },
],
columns: ['name', 'id', 'view_count'],View on GitHub (pinned to 49907e53dc)
Solutions
- Pass the cover URI from a previously uploaded video: `douyin hashtag suggest --cover <cover_uri>`
- If you want keyword-based lookup, use `douyin hashtag search --keyword <词>` instead
- Upload the video (or run the draft flow) first to obtain a cover_uri, then call suggest
Example fix
// before opencli douyin hashtag suggest // missing cover // after opencli douyin hashtag suggest --cover "douyin://cover/xxxx"
Defensive patterns
Strategy: validation
Validate before calling
const cover = (process.env.COVER_URI ?? '').trim();
if (!cover) throw new Error('suggest requires --cover <cover_uri>; use search --keyword for text lookup'); Type guard
const hasCover = (c) => typeof c === 'string' && c.trim().length > 0;
Try / catch
try {
await cli.hashtag({ action: 'suggest', cover });
} catch (e) {
if (e instanceof ArgumentError && e.message.includes('suggest 需要 --cover')) {
await cli.hashtag({ action: 'search', keyword: fallbackKeyword });
} else throw e;
} Prevention
- Complete the video upload/draft flow first so a cover_uri exists
- Default to the search action when you only have a keyword, not a cover
- Guard cover variables in scripts with ${COVER:?msg} to fail fast
When it happens
Trigger: Running `douyin hashtag suggest` without `--cover <cover_uri>`, with an empty string, or with whitespace-only input; also using suggest when the user actually wanted keyword search.
Common situations: Mixing up the two actions (search vs suggest), not having uploaded the video yet so no cover_uri exists, or scripts passing an unset cover variable.
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
- symbol is required
- <username> is required
- <game-url> is required
- Either --product-id or --url is required
- --city is required (numeric city ID from `ctrip search` or `
AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29).
Data as JSON: /api/errors/8741f084ecc773c9.
Report an issue: GitHub.