{"record":{"id":"c6adf9c57ad14a2f","repo":"jackwener/OpenCLI","slug":"cannot-use-both-to-and-to-fid","errorCode":null,"errorMessage":"Cannot use both --to and --to-fid","messagePattern":"Cannot use both --to and --to-fid","errorType":"validation","errorClass":"ArgumentError","httpStatus":null,"severity":"error","filePath":"clis/quark/mv.js","lineNumber":28,"sourceCode":"    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';\n            if (!completed)\n                throw new CommandExecutionError('quark: Move task timed out');","sourceCodeStart":10,"sourceCodeEnd":46,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/quark/mv.js#L10-L46","documentation":"quark mv rejects specifying both --to (path) and --to-fid (id) for the destination, since the two could disagree; it throws ArgumentError('Cannot use both --to and --to-fid'). Provide exactly one destination selector so the target folder is unambiguous.","triggerScenarios":"Invoking quark mv with both destination flags, e.g. `quark mv --fids fid1 --to /docs --to-fid fid_9`.","commonSituations":"Wrapper scripts appending a default --to while the caller also passed --to-fid; copy-pasted commands combining examples; migration from path-based to id-based invocations leaving both flags in place.","solutions":["Drop --to and keep --to-fid when you already know the target folder id (faster, avoids findFolder lookup).","Otherwise drop --to-fid and let the CLI resolve --to by folder name.","Centralize destination selection in one config key so wrapper scripts never emit both flags."],"exampleFix":"// before\nquark mv --fids fid1 --to /docs --to-fid fid_9\n// after\nquark mv --fids fid1 --to-fid fid_9","handlingStrategy":"validation","validationCode":"if (opts.to && opts['to-fid']) {\n  throw new Error('Pass only one of --to or --to-fid to quark mv');\n}","typeGuard":"function hasExactlyOneDestination(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 (/Cannot use both --to and --to-fid/.test(String(e.message))) {\n    console.error('Drop --to and keep --to-fid (or vice versa), then retry.');\n  } else throw e;\n}","preventionTips":["Source destination flags from one config key to avoid duplicates","Prefer --to-fid in scripts; reserve --to for interactive use","Wrapper scripts should assert flag exclusivity before exec","Document the either/or contract where the CLI is embedded"],"tags":["argument-validation","quark","mv","cli","mutually-exclusive-flags"],"backgroundTag":"mutually-exclusive-arguments","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T17:17:51.833Z"}