jackwener/OpenCLI · error · ArgumentError
Either --to or --to-fid is required
Error message
Either --to or --to-fid is required
What it means
quark mv requires a destination: either a target folder path (--to, resolved via findFolder) or a target folder id (--to-fid). When neither is present, the CLI throws ArgumentError('Either --to or --to-fid is required') before making any API request.
Source
Thrown at clis/quark/mv.js:26
description: 'Move files to a folder in your Quark Drive',
domain: 'pan.quark.cn',
strategy: Strategy.COOKIE,
defaultFormat: 'json',
args: [
{ name: 'fids', required: true, positional: true, help: 'File IDs to move (comma-separated)' },
{ name: 'to', default: '', help: 'Destination folder path (required unless --to-fid is set)' },
{ name: 'to-fid', default: '', help: 'Destination folder ID (overrides --to)' },
{ name: 'timeout', type: 'int', required: false, default: 120, help: 'Max seconds for the overall command (default: 120)' },
],
func: async (page, kwargs) => {
const to = kwargs.to;
const toFid = kwargs['to-fid'];
const fids = kwargs.fids;
const fidList = [...new Set(fids.split(',').map(id => id.trim()).filter(Boolean))];
if (fidList.length === 0)
throw new ArgumentError('No fids provided');
if (!to && !toFid)
throw new ArgumentError('Either --to or --to-fid is required');
if (to && toFid)
throw new ArgumentError('Cannot use both --to and --to-fid');
const targetFid = toFid || await findFolder(page, to);
const data = await apiPost(page, `${DRIVE_API}/move?pr=ucpro&fr=pc`, {
filelist: fidList,
to_pdir_fid: targetFid,
});
const result = {
status: 'pending',
count: fidList.length,
destination: to || toFid,
task_id: data.task_id,
completed: false,
};
if (data.task_id) {
const completed = await pollTask(page, data.task_id);
result.completed = completed;
result.status = completed ? 'ok' : 'error';View on GitHub (pinned to 49907e53dc)
Solutions
- Add the destination: --to /target/path for a named folder or --to-fid <fid> for a direct id.
- If the path may be ambiguous, resolve it once to a fid and use --to-fid for determinism.
- In scripts, fail early with your own check that one destination flag is set before invoking the CLI.
Example fix
// before await run(['quark', 'mv', '--fids', 'fid1']); // after await run(['quark', 'mv', '--fids', 'fid1', '--to', '/archive']);
Defensive patterns
Strategy: validation
Validate before calling
if (!opts.to && !opts['to-fid']) {
throw new Error('quark mv needs --to <path> or --to-fid <id>');
} Type guard
function hasDestination(opts) {
return Boolean(opts.to) || Boolean(opts['to-fid']);
} Try / catch
try {
await run(['quark', 'mv', '--fids', fids, ...destFlags]);
} catch (e) {
if (/Either --to or --to-fid is required/.test(String(e.message))) {
console.error('Add a destination: --to /path or --to-fid <id>.');
} else throw e;
} Prevention
- Make the destination a required parameter in wrapper scripts
- Validate config keys before mapping them to CLI flags
- Prefer --to-fid for unambiguous scripted moves
- Dry-run the command line and assert required flags exist
When it happens
Trigger: Invoking quark mv with valid --fids but omitting both destination flags, e.g. `quark mv --fids fid1`.
Common situations: Forgetting the destination flag in a hand-typed command; script refactors removing --to without adding --to-fid; config-driven invocations where the destination key was missing/misspelled so the flag was never emitted.
Understand the failure class
Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.
Related errors
- No fids provided
- Cannot use both --to and --to-fid
- Folder name cannot be empty
- Cannot use both --parent and --parent-fid
- --output-file requires --all
AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29).
Data as JSON: /api/errors/9d137e6a96e34149.
Report an issue: GitHub.