{"record":{"id":"7f6da267d1640643","repo":"jackwener/OpenCLI","slug":"either-to-or-to-fid-is-required-7f6da2","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/save.js","lineNumber":41,"sourceCode":"    defaultFormat: 'json',\n    args: [\n        { name: 'url', required: true, positional: true, help: 'Quark share URL or pwd_id' },\n        { name: 'to', default: '', help: 'Destination folder path' },\n        { name: 'to-fid', default: '', help: 'Destination folder ID (overrides --to)' },\n        { name: 'fids', default: '', help: 'File IDs to save (comma-separated, from share-tree). Omit to save all.' },\n        { name: 'stoken', default: '', help: 'Share token (from share-tree output, required with --fids)' },\n        { name: 'passcode', default: '', help: 'Share passcode (if required)' },\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 url = kwargs.url;\n        const to = kwargs.to;\n        const toFid = kwargs['to-fid'];\n        const fids = kwargs.fids;\n        const stokenArg = kwargs.stoken;\n        const passcode = kwargs.passcode;\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 pwdId = extractPwdId(url);\n        const saveAll = !fids;\n        let stoken;\n        let fidList;\n        if (saveAll) {\n            stoken = stokenArg || await getToken(page, pwdId, passcode);\n            fidList = [];\n        }\n        else {\n            if (!stokenArg)\n                throw new ArgumentError('--stoken is required when using --fids');\n            stoken = stokenArg;\n            fidList = [...new Set(fids.split(',').map(id => id.trim()).filter(Boolean))];\n        }\n        const targetFid = toFid || await findFolder(page, to);\n        const taskId = await saveShare(page, pwdId, stoken, fidList, targetFid, saveAll);","sourceCodeStart":23,"sourceCodeEnd":59,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/quark/save.js#L23-L59","documentation":"Thrown by clis/quark/save.js when neither --to (target folder path) nor --to-fid (target folder id) is provided for a share-save operation. The command needs exactly one destination, so it raises ArgumentError before contacting the API.","triggerScenarios":"Running the save command with only the share URL (and optional --fids) but omitting both destination flags; forgetting that the destination is mandatory even when saving all files.","commonSituations":"Copy-pasting an example command without the destination flags; assuming files save to the drive root by default; scripts where the destination variable is unset.","solutions":["Add a destination: --to /my/folder or --to-fid <folder_fid>.","If you have the folder id from a prior listing, prefer --to-fid to avoid path lookup.","In scripts, default the destination variable to a known folder before invoking."],"exampleFix":"// before\nquark save https://pan.quark.cn/s/abc123\n// after\nquark save https://pan.quark.cn/s/abc123 --to /saved","handlingStrategy":"validation","validationCode":"if (!process.env.TO && !process.env.TO_FID) {\n  throw new Error('save requires --to or --to-fid');\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always include exactly one destination flag in save commands.","Default a destination folder in wrapper scripts.","Prefer --to-fid when the folder id is already known."],"tags":["validation","argument-error","quark"],"backgroundTag":"missing-required-argument","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}