jackwener/OpenCLI · error · ArgumentError
Cannot use both --parent and --parent-fid
Error message
Cannot use both --parent and --parent-fid
What it means
quark mkdir accepts the target parent either by path (--parent, resolved via findFolder) or directly by id (--parent-fid). Supplying both is ambiguous, so the CLI throws ArgumentError('Cannot use both --parent and --parent-fid') before any API call. Exactly one parent selector must be provided.
Source
Thrown at clis/quark/mkdir.js:22
cli({
site: 'quark',
name: 'mkdir',
access: 'write',
description: 'Create a folder in your Quark Drive',
domain: 'pan.quark.cn',
strategy: Strategy.COOKIE,
defaultFormat: 'json',
args: [
{ name: 'name', required: true, positional: true, help: 'Folder name' },
{ name: 'parent', help: 'Parent folder path (resolved by name)' },
{ name: 'parent-fid', help: 'Parent folder fid (use directly)' },
],
func: async (page, kwargs) => {
const name = kwargs.name;
if (!name.trim())
throw new ArgumentError('Folder name cannot be empty');
if (kwargs.parent && kwargs['parent-fid']) {
throw new ArgumentError('Cannot use both --parent and --parent-fid');
}
const parentFid = kwargs['parent-fid']
? kwargs['parent-fid']
: kwargs.parent
? await findFolder(page, kwargs.parent)
: '0';
const data = await apiPost(page, `${DRIVE_API}?pr=ucpro&fr=pc`, {
pdir_fid: parentFid,
file_name: name,
dir_path: '',
dir_init_lock: false,
});
return { status: 'ok', fid: data.fid, name };
},
});
View on GitHub (pinned to 49907e53dc)
Solutions
- Remove one of the two flags — keep --parent-fid if you already know the fid, otherwise keep --parent with the path.
- In wrapper scripts, assert only one parent flag is emitted before invoking the CLI.
- Resolve the path to a fid yourself once (via findFolder/listing) and standardize on --parent-fid for speed and determinism.
Example fix
// before quark mkdir --name reports --parent /docs --parent-fid fid_123 // after quark mkdir --name reports --parent-fid fid_123
Defensive patterns
Strategy: validation
Validate before calling
const flags = collectFlags(args);
if (flags.includes('--parent') && flags.includes('--parent-fid')) {
throw new Error('Choose either --parent (path) or --parent-fid, not both');
} Type guard
function hasExactlyOneParentSelector(opts) {
return Boolean(opts.parent) !== Boolean(opts['parent-fid']);
} Try / catch
try {
await run(['quark', 'mkdir', '--name', name, ...parentFlags]);
} catch (e) {
if (/Cannot use both --parent and --parent-fid/.test(String(e.message))) {
console.error('Remove one of --parent / --parent-fid and retry.');
} else throw e;
} Prevention
- Standardize on one parent selector style across your scripts
- Resolve paths to fids once and use --parent-fid thereafter
- In wrappers, emit parent flags from a single config source
- Add a pre-invocation assert that only one parent flag is present
When it happens
Trigger: Invoking quark mkdir with both flags simultaneously, e.g. `quark mkdir --name x --parent /docs --parent-fid abc123`.
Common situations: Copy-pasting an example command that already included --parent-fid and adding --parent yourself; wrapper scripts concatenating flags from config and CLI; migration from fid-based invocations leaving both flags set.
Related errors
- Folder name cannot be empty
- Cannot use both --to and --to-fid
- No fids provided
- Either --to or --to-fid is required
- <train-no> "${trainNo}" does not look like a 12306 internal
AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29).
Data as JSON: /api/errors/d419cd1d4b1b0078.
Report an issue: GitHub.