{"record":{"id":"4c780bebbe6c3c5e","repo":"jackwener/OpenCLI","slug":"cannot-use-both-to-and-to-fid-4c780b","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/save.js","lineNumber":43,"sourceCode":"        { 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);\n        const result = {\n            success: false,","sourceCodeStart":25,"sourceCodeEnd":61,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/quark/save.js#L25-L61","documentation":"Thrown by clis/quark/save.js when both --to and --to-fid are supplied. The destination is ambiguous (path vs folder id), so the command refuses to run with an ArgumentError rather than guessing which one to honor.","triggerScenarios":"A command line like quark save <url> --to /folder --to-fid abc123; wrappers that always append --to-fid while the user also passes --to.","commonSituations":"Combining a hand-written command with generated flags from a script or alias; migrating commands from path-style to id-style and forgetting to remove the old flag.","solutions":["Remove one of the two flags, keeping either --to or --to-fid.","If both values are known and you prefer precision, keep --to-fid and drop --to.","Audit wrapper scripts/aliases for hardcoded destination flags that may collide with user input."],"exampleFix":"// before\nquark save $URL --to /saved --to-fid $FID\n// after\nquark save $URL --to-fid $FID","handlingStrategy":"validation","validationCode":"if (to && toFid) {\n  throw new Error('Pass only one of --to or --to-fid');\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Standardize on one destination style (fid) across scripts.","Audit aliases/wrappers for hardcoded destination flags.","Build commands from a single flags object to prevent duplicates."],"tags":["validation","argument-error","conflicting-flags","quark"],"backgroundTag":"conflicting-arguments","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}