jackwener/OpenCLI · error · ArgumentError
--approve-kinds must contain at least one approval kind
Error message
--approve-kinds must contain at least one approval kind
What it means
After expanding items (where 'all' expands to terminal/delete/keep) and de-duplicating, normalizeApprovalKinds requires at least one approval kind. An empty result means nothing to approve was specified, so the library throws this ArgumentError rather than silently running with no approvals.
Source
Thrown at clis/trae-cn/utils.js:87
export function normalizeApprovalKinds(value, fallback = TRAE_CN_APPROVAL_DEFAULT_KINDS.join(',')) {
const raw = value === undefined || value === null || value === '' ? fallback : value;
const parts = Array.isArray(raw) ? raw : String(raw).split(',');
const expanded = [];
for (const part of parts) {
const item = String(part || '').trim().toLowerCase();
if (!item) continue;
if (item === 'all') {
expanded.push('terminal', 'delete', 'keep');
continue;
}
if (!['terminal', 'delete', 'keep'].includes(item)) {
throw new ArgumentError('--approve-kinds must contain only terminal, delete, keep, or all');
}
expanded.push(item);
}
const unique = Array.from(new Set(expanded));
if (unique.length === 0) {
throw new ArgumentError('--approve-kinds must contain at least one approval kind');
}
return unique;
}
export function normalizeApprovalLimit(value, fallback = 1) {
const limit = value === undefined || value === null ? fallback : Number(value);
if (!Number.isInteger(limit) || limit < 1 || limit > 20) {
throw new ArgumentError('--limit must be an integer between 1 and 20');
}
return limit;
}
export function ensurePrompt(text) {
const prompt = typeof text === 'string' ? text : '';
if (!prompt.trim()) {
throw new ArgumentError('text must not be empty');
}
return prompt;View on GitHub (pinned to 49907e53dc)
Solutions
- Pass at least one kind, e.g. --approve-kinds terminal
- Use --approve-kinds all to approve everything
- Remove the empty flag so the library default applies if one exists
Example fix
// before --approve-kinds "" // after --approve-kinds all
Defensive patterns
Strategy: validation
Validate before calling
const items = (approveKinds ?? '').split(',').map(s => s.trim()).filter(Boolean);
if (items.length === 0) throw new Error('--approve-kinds requires at least one of terminal, delete, keep, or all'); Type guard
const hasApprovalKinds = (v) => typeof v === 'string' && v.split(',').map(s=>s.trim()).filter(Boolean).length > 0; Try / catch
try { kinds = normalizeApprovalKinds(raw); } catch (e) { if (/at least one approval kind/.test(e.message)) { kinds = ['terminal']; console.warn('Empty --approve-kinds, defaulting to terminal'); } else throw e; } Prevention
- Never pass empty strings for list-style flags
- Default to 'all' or a sane kind in wrapper scripts
- Trim and filter list inputs before passing them through
When it happens
Trigger: Calling kinds/approvalKinds with --approve-kinds '' or a value that yields an empty list after trimming/expansion.
Common situations: Empty string passed through shell quoting, or config files where the kinds key is present but blank.
Understand the failure class
Background: "Unknown argument", "Invalid value", and "must be one of": invalid CLI argument errors explained — this error's family across 35 libraries.
Related errors
- ${label} cannot be empty
- Instagram note content cannot be empty.
- prompt cannot be empty
- packagist ${label} cannot be empty
- No fids provided
AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29).
Data as JSON: /api/errors/9e952d4cd2385475.
Report an issue: GitHub.