{"record":{"id":"1f75f7ec4bb7e772","repo":"jackwener/OpenCLI","slug":"stoken-is-required-when-using-fids","errorCode":null,"errorMessage":"--stoken is required when using --fids","messagePattern":"--stoken is required when using --fids","errorType":"validation","errorClass":"ArgumentError","httpStatus":null,"severity":"error","filePath":"clis/quark/save.js","lineNumber":54,"sourceCode":"        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,\n            task_id: taskId,\n            saved_to: to || toFid,\n            target_fid: targetFid,\n            ...(saveAll ? {} : { fids: fidList }),\n        };\n        if (taskId) {\n            const completed = await pollTask(page, taskId, (task) => {\n                result.save_count = task.save_as?.save_as_sum_num;\n            });\n            result.completed = completed;\n            result.success = completed;","sourceCodeStart":36,"sourceCodeEnd":72,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/quark/save.js#L36-L72","documentation":"Thrown by clis/quark/save.js when selective saving (--fids) is used without --stoken. The stoken is the share token obtained from the share's password/token endpoint; saving only specific fids requires it up front, whereas save-all can fetch it automatically via getToken.","triggerScenarios":"Running quark save <url> --fids fid1,fid2 without --stoken; assuming the tool will fetch the token for partial saves as it does for full saves.","commonSituations":"Scripting selective saves after obtaining stoken in a previous step but forgetting to pass it through; copy-pasting partial-save examples that omitted the flag.","solutions":["Add --stoken <token> (the pwd_id/stoken from the share) when using --fids.","If you don't have the stoken, either omit --fids to save everything (token is fetched automatically) or fetch it first with a token command.","In scripts, capture the stoken from the earlier step and pass it explicitly."],"exampleFix":"// before\nquark save $URL --fids fid1,fid2 --to /saved\n// after\nquark save $URL --fids fid1,fid2 --stoken $STOKEN --to /saved","handlingStrategy":"validation","validationCode":"if (fids && !stoken) {\n  throw new Error('--fids requires --stoken; fetch the share stoken first');\n}","typeGuard":"function hasStoken(opts) {\n  return typeof opts.stoken === 'string' && opts.stoken.length > 0;\n}","tryCatchPattern":null,"preventionTips":["Capture and pass the stoken from the token-fetch step whenever using --fids.","Omit --fids for save-all if you don't have a stoken.","Keep stokens per share; they are not interchangeable across shares."],"tags":["validation","argument-error","auth-token","quark"],"backgroundTag":"missing-required-argument","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}