{"record":{"id":"9d137e6a96e34149","repo":"jackwener/OpenCLI","slug":"either-to-or-to-fid-is-required","errorCode":null,"errorMessage":"Either --to or --to-fid is required","messagePattern":"Either --to or --to-fid is required","errorType":"validation","errorClass":"ArgumentError","httpStatus":null,"severity":"error","filePath":"clis/quark/mv.js","lineNumber":26,"sourceCode":"    description: 'Move files to a folder in your Quark Drive',\n    domain: 'pan.quark.cn',\n    strategy: Strategy.COOKIE,\n    defaultFormat: 'json',\n    args: [\n        { name: 'fids', required: true, positional: true, help: 'File IDs to move (comma-separated)' },\n        { name: 'to', default: '', help: 'Destination folder path (required unless --to-fid is set)' },\n        { name: 'to-fid', default: '', help: 'Destination folder ID (overrides --to)' },\n        { name: 'timeout', type: 'int', required: false, default: 120, help: 'Max seconds for the overall command (default: 120)' },\n    ],\n    func: async (page, kwargs) => {\n        const to = kwargs.to;\n        const toFid = kwargs['to-fid'];\n        const fids = kwargs.fids;\n        const fidList = [...new Set(fids.split(',').map(id => id.trim()).filter(Boolean))];\n        if (fidList.length === 0)\n            throw new ArgumentError('No fids provided');\n        if (!to && !toFid)\n            throw new ArgumentError('Either --to or --to-fid is required');\n        if (to && toFid)\n            throw new ArgumentError('Cannot use both --to and --to-fid');\n        const targetFid = toFid || await findFolder(page, to);\n        const data = await apiPost(page, `${DRIVE_API}/move?pr=ucpro&fr=pc`, {\n            filelist: fidList,\n            to_pdir_fid: targetFid,\n        });\n        const result = {\n            status: 'pending',\n            count: fidList.length,\n            destination: to || toFid,\n            task_id: data.task_id,\n            completed: false,\n        };\n        if (data.task_id) {\n            const completed = await pollTask(page, data.task_id);\n            result.completed = completed;\n            result.status = completed ? 'ok' : 'error';","sourceCodeStart":8,"sourceCodeEnd":44,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/quark/mv.js#L8-L44","documentation":"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.","triggerScenarios":"Invoking quark mv with valid --fids but omitting both destination flags, e.g. `quark mv --fids fid1`.","commonSituations":"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.","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."],"exampleFix":"// before\nawait run(['quark', 'mv', '--fids', 'fid1']);\n// after\nawait run(['quark', 'mv', '--fids', 'fid1', '--to', '/archive']);","handlingStrategy":"validation","validationCode":"if (!opts.to && !opts['to-fid']) {\n  throw new Error('quark mv needs --to <path> or --to-fid <id>');\n}","typeGuard":"function hasDestination(opts) {\n  return Boolean(opts.to) || Boolean(opts['to-fid']);\n}","tryCatchPattern":"try {\n  await run(['quark', 'mv', '--fids', fids, ...destFlags]);\n} catch (e) {\n  if (/Either --to or --to-fid is required/.test(String(e.message))) {\n    console.error('Add a destination: --to /path or --to-fid <id>.');\n  } else throw e;\n}","preventionTips":["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"],"tags":["argument-validation","quark","mv","cli","missing-flag"],"backgroundTag":"missing-required-argument","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}