jackwener/OpenCLI · warning · ArgumentError
Unknown tag: ${value}
Error message
Unknown tag: ${value} What it means
resolveTag normalizes the user-supplied value and tries to match it against the live tag list (by id, name, or slug) fetched from linux.do; if no record matches it throws ArgumentError. The hint directs the user to `opencli linux-do tags` to enumerate valid tags. This is input validation, not a network failure — the tag list was retrieved successfully but nothing matched.
Source
Thrown at clis/linux-do/feed.js:246
function topicListRichFromJson(data, limit) {
const topics = data?.topic_list?.topics ?? [];
return topics.slice(0, limit).map((t) => ({
title: t.fancy_title ?? t.title ?? '',
replies: normalizeReplyCount(t.posts_count),
created: toLocalTime(t.created_at),
likes: t.like_count ?? 0,
views: t.views ?? 0,
url: `https://linux.do/t/topic/${t.id}`,
}));
}
/**
* 解析标签,支持 id、name、slug 三种输入。
*/
async function resolveTag(page, value) {
const liveTag = findMatchingTag(await fetchLiveTags(page), value);
if (liveTag)
return liveTag;
throw new ArgumentError(`Unknown tag: ${value}`, 'Use "opencli linux-do tags" to list available tags');
}
/**
* 解析分类,并补齐父分类信息。
*/
async function resolveCategory(page, value) {
const liveCategory = findMatchingCategory(await fetchLiveCategories(page), value);
if (liveCategory)
return liveCategory;
throw new ArgumentError(`Unknown category: ${value}`, 'Use "opencli linux-do categories" to list available categories');
}
/**
* 将命令参数转换为最终请求地址
*/
async function resolveFeedRequest(page, kwargs) {
const view = (kwargs.view || 'latest');
const period = (kwargs.period || 'weekly');
if (kwargs.period && view !== 'top') {
throw new ArgumentError('--period is only valid with --view top');View on GitHub (pinned to 49907e53dc)
Solutions
- Run `opencli linux-do tags` and copy the exact id, name, or slug from the output
- Check for typos or removed tags; tags can be deleted or renamed on the forum
- If you meant a category, use --category instead of --tag
- Clear ~/.opencli/cache/linux-do/tags.json if you suspect the cached tag list is stale (TTL is 24h)
Example fix
// before (shell) opencli linux-do feed --tag "AI 编程" // Unknown tag: AI 编程 // after (shell) opencli linux-do tags # find the matching slug, e.g. 'ai-coding' opencli linux-do feed --tag ai-coding
Defensive patterns
Strategy: validation
Validate before calling
import { execCommand } from './browser-runner.js';
// Validate the tag before calling the feed command
const tags = await fetchLiveTags(page); // same list resolveTag uses
function isValidTag(value) {
const norm = s => s.trim().replace(/\s+/g, ' ').toLowerCase();
return tags.some(t =>
String(t.id) === value.trim() ||
norm(t.name) === norm(value) ||
norm(t.slug) === norm(value));
}
if (!isValidTag(userValue)) {
console.error('Invalid tag. Run: opencli linux-do tags');
process.exit(1);
} Type guard
function isKnownTag(records, value) {
const norm = s => String(s).trim().replace(/\s+/g, ' ').toLowerCase();
return records.some(r =>
String(r.id) === value.trim() ||
norm(r.name) === norm(value) ||
norm(r.slug) === norm(value));
} Try / catch
import { ArgumentError } from '@jackwener/opencli/errors';
try {
await tag(value);
} catch (err) {
if (err instanceof ArgumentError && err.message.startsWith('Unknown tag:')) {
console.error(`${err.message}\n${err.hint || 'Run: opencli linux-do tags'}`);
process.exitCode = 1;
} else {
throw err;
}
} Prevention
- Always pick tag values from `opencli linux-do tags` output rather than typing from memory
- Prefer slug or numeric id over display names
- Remember the CLI tolerates case/space differences but not punctuation or renamed tags
- Clear the 24h tags cache after forum tag reorganizations
When it happens
Trigger: `opencli linux-do feed --tag <value>` where value matches no tag id, name, or slug: typo, wrong casing/spacing beyond normalization, using a display name instead of slug, referencing a deleted tag, or passing a category name to --tag.
Common situations: Typing 'ChatGPT' when the slug is 'chatgpt' (handled) vs. a renamed/deleted tag; copying a tag title with extra punctuation; using an id from an outdated cached list; confusing tag with category values.
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
- Unknown category: ${value}
- coingecko limit must be a positive integer
- Unknown sort "${sortKey}". Valid: ${Object.keys(SORTS).join(
- INVALID_ARGUMENT
- unknown mode "${mode}"
AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29).
Data as JSON: /api/errors/9f4542dd6934b3fc.
Report an issue: GitHub.