jackwener/OpenCLI · error · ArgumentError
Unsupported novel download format: ${format}. Supported form
Error message
Unsupported novel download format: ${format}. Supported formats: txt, md. What it means
After type-checking, normalizeNovelFileFormat lowercases the value (defaulting undefined to 'txt') and throws this ArgumentError if the result is neither 'txt' nor 'md'. This guards against unsupported output formats before any file is written.
Source
Thrown at clis/pixiv/novel-download-utils.js:53
...body,
id: novelId,
title,
userName: author,
userId,
content: body.content,
createdDate,
wordCount,
bookmarkCount,
};
}
export function normalizeNovelFileFormat(value) {
if (value !== undefined && typeof value !== 'string') {
throw new ArgumentError('Novel download format must be txt or md');
}
const format = (value ?? 'txt').toLowerCase();
if (format !== 'txt' && format !== 'md') {
throw new ArgumentError(`Unsupported novel download format: ${format}. Supported formats: txt, md.`);
}
return format;
}
export function normalizePixivOutputRoot(value, fallback) {
if (value !== undefined && typeof value !== 'string') {
throw new ArgumentError('output must be a directory path');
}
const raw = value ?? fallback;
if (!raw || raw.includes('\0')) {
throw new ArgumentError('output must be a non-empty directory path');
}
const resolved = path.resolve(raw);
let ancestor = resolved;
const missingParts = [];
let ancestorStat;
while (!ancestorStat) {
try {View on GitHub (pinned to 49907e53dc)
Solutions
- Use exactly 'txt' or 'md' as the format value
- Trim whitespace and remove punctuation from the value before passing it
- Update the calling script/config to one of the supported formats
- If another format is needed, extend normalizeNovelFileFormat's allowed set
Example fix
// before pixiv novel-download --format markdown // after pixiv novel-download --format md
Defensive patterns
Strategy: validation
Validate before calling
const allowed = new Set(['txt', 'md']);
const fmt = String(options.format ?? 'txt').trim().toLowerCase();
if (!allowed.has(fmt)) throw new Error(`Unsupported format: ${fmt}; use txt or md`); Type guard
const isSupportedFormat = (v) => v === 'txt' || v === 'md';
Try / catch
try {
await novelDownload({ format });
} catch (e) {
if (/Unsupported novel download format/.test(e.message)) {
console.error('Use --format txt or --format md');
} else throw e;
} Prevention
- Use only 'txt' or 'md' for the format option
- Trim and lowercase values before passing through wrappers
- Do not assume other formats (pdf/html) are supported
- List allowed formats in your own CLI help/config docs
When it happens
Trigger: Passing --format pdf, docx, html, or any misspelling like 'markdown' or 'text' to the novel download command.
Common situations: Users assume other formats are supported; typo'd values like 'md.' or 'TXT ' with punctuation/whitespace (note: no trimming is done, so ' txt' fails); scripted values from an upstream config.
Related errors
- douyin delete aweme_id cannot be empty
- douyin delete aweme_id must be a numeric id
- eastmoney convertible --limit must be an integer between 1 a
- INVALID_ARGUMENT
- limit must be a positive integer ≤ ${max}
AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29).
Data as JSON: /api/errors/9c9094a66687a4af.
Report an issue: GitHub.