jackwener/OpenCLI · error · ArgumentError
--stoken is required when using --fids
Error message
--stoken is required when using --fids
What it means
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.
Source
Thrown at clis/quark/save.js:54
const toFid = kwargs['to-fid'];
const fids = kwargs.fids;
const stokenArg = kwargs.stoken;
const passcode = kwargs.passcode;
if (!to && !toFid)
throw new ArgumentError('Either --to or --to-fid is required');
if (to && toFid)
throw new ArgumentError('Cannot use both --to and --to-fid');
const pwdId = extractPwdId(url);
const saveAll = !fids;
let stoken;
let fidList;
if (saveAll) {
stoken = stokenArg || await getToken(page, pwdId, passcode);
fidList = [];
}
else {
if (!stokenArg)
throw new ArgumentError('--stoken is required when using --fids');
stoken = stokenArg;
fidList = [...new Set(fids.split(',').map(id => id.trim()).filter(Boolean))];
}
const targetFid = toFid || await findFolder(page, to);
const taskId = await saveShare(page, pwdId, stoken, fidList, targetFid, saveAll);
const result = {
success: false,
task_id: taskId,
saved_to: to || toFid,
target_fid: targetFid,
...(saveAll ? {} : { fids: fidList }),
};
if (taskId) {
const completed = await pollTask(page, taskId, (task) => {
result.save_count = task.save_as?.save_as_sum_num;
});
result.completed = completed;
result.success = completed;View on GitHub (pinned to 49907e53dc)
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.
Example fix
// before quark save $URL --fids fid1,fid2 --to /saved // after quark save $URL --fids fid1,fid2 --stoken $STOKEN --to /saved
Defensive patterns
Strategy: validation
Validate before calling
if (fids && !stoken) {
throw new Error('--fids requires --stoken; fetch the share stoken first');
} Type guard
function hasStoken(opts) {
return typeof opts.stoken === 'string' && opts.stoken.length > 0;
} Prevention
- 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.
When it happens
Trigger: 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.
Common situations: 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.
Understand the failure class
Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.
Related errors
- New name cannot be empty
- No fids provided
- Either --to or --to-fid is required
- Cannot use both --to and --to-fid
- Invalid Quark share URL: ${url}
AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29).
Data as JSON: /api/errors/1f75f7ec4bb7e772.
Report an issue: GitHub.