jackwener/OpenCLI · warning · CommandExecutionError
Invalid linux.do topic id: ${String(kwargs.id ?? '')}
Error message
Invalid linux.do topic id: ${String(kwargs.id ?? '')} What it means
The topic-content command declares id as a required int positional. Before fetching, the func coerces kwargs.id via Number and requires a positive integer; otherwise it throws CommandExecutionError with the raw value. This validates input before hitting the network.
Source
Thrown at clis/linux-do/topic-content.js:139
return result.data;
}
cli({
site: 'linux-do',
name: 'topic-content',
access: 'read',
description: 'Get the main topic body as Markdown',
domain: LINUX_DO_DOMAIN,
strategy: Strategy.COOKIE,
browser: true,
defaultFormat: 'plain',
args: [
{ name: 'id', positional: true, type: 'int', required: true, help: 'Topic ID' },
],
columns: ['content'],
func: async (page, kwargs) => {
const id = Number(kwargs.id);
if (!Number.isInteger(id) || id <= 0) {
throw new CommandExecutionError(`Invalid linux.do topic id: ${String(kwargs.id ?? '')}`);
}
const payload = await fetchTopicPayload(page, id);
return [extractTopicContent(payload, id)];
},
});
export const __test__ = {
buildTopicMarkdownDocument,
extractTopicContent,
normalizeTopicPayload,
};
View on GitHub (pinned to 49907e53dc)
Solutions
- Pass the numeric topic ID only: `topic-content 12345`.
- Extract the ID from a pasted URL (the trailing number in /t/<slug>/<id>).
- Quote the ID in scripts to avoid shell mangling.
- Trim/validate the input before invoking the CLI.
Example fix
// before cli --site linux-do --name topic-content "https://linux.do/t/some-slug/12345" // after cli --site linux-do --name topic-content 12345
Defensive patterns
Strategy: validation
Validate before calling
const id = Number(url.match(/\/t\/[^/]+\/(\d+)/)?.[1] ?? process.argv[2]);
if (!Number.isInteger(id) || id <= 0) {
throw new Error(`Invalid topic id: ${process.argv[2]}`);
} Type guard
const isValidTopicId = (v) => Number.isInteger(Number(v)) && Number(v) > 0;
Try / catch
try {
return await cliRun(['topic-content', String(id)]);
} catch (e) {
if (/Invalid linux\.do topic id/.test(e?.message ?? '')) {
console.error('Pass the numeric topic ID, not a URL or slug.');
} else throw e;
} Prevention
- Extract numeric IDs from topic URLs before invoking
- Validate ID inputs in wrapper scripts
- Quote positional args in shell scripts
When it happens
Trigger: Running the command with a missing, non-numeric, zero, negative, or float id — e.g. `topic-content abc`, `topic-content`, `topic-content 0`, or a URL slug pasted instead of the numeric ID.
Common situations: Pasting the full topic URL (e.g. https://linux.do/t/slug/12345) instead of extracting 12345; shell variable empty in a script; leading/trailing whitespace.
Related errors
- ${label} must be a non-negative integer, got ${JSON.stringif
- limit must be a positive integer
- bilibili comment ${label} must be a positive integer
- bilibili comment message cannot be empty
- bilibili unfollow target cannot be empty
AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29).
Data as JSON: /api/errors/012ff470231046cb.
Report an issue: GitHub.