{"record":{"id":"d419cd1d4b1b0078","repo":"jackwener/OpenCLI","slug":"cannot-use-both-parent-and-parent-fid","errorCode":null,"errorMessage":"Cannot use both --parent and --parent-fid","messagePattern":"Cannot use both --parent and --parent-fid","errorType":"validation","errorClass":"ArgumentError","httpStatus":null,"severity":"error","filePath":"clis/quark/mkdir.js","lineNumber":22,"sourceCode":"cli({\n    site: 'quark',\n    name: 'mkdir',\n    access: 'write',\n    description: 'Create a folder in your Quark Drive',\n    domain: 'pan.quark.cn',\n    strategy: Strategy.COOKIE,\n    defaultFormat: 'json',\n    args: [\n        { name: 'name', required: true, positional: true, help: 'Folder name' },\n        { name: 'parent', help: 'Parent folder path (resolved by name)' },\n        { name: 'parent-fid', help: 'Parent folder fid (use directly)' },\n    ],\n    func: async (page, kwargs) => {\n        const name = kwargs.name;\n        if (!name.trim())\n            throw new ArgumentError('Folder name cannot be empty');\n        if (kwargs.parent && kwargs['parent-fid']) {\n            throw new ArgumentError('Cannot use both --parent and --parent-fid');\n        }\n        const parentFid = kwargs['parent-fid']\n            ? kwargs['parent-fid']\n            : kwargs.parent\n                ? await findFolder(page, kwargs.parent)\n                : '0';\n        const data = await apiPost(page, `${DRIVE_API}?pr=ucpro&fr=pc`, {\n            pdir_fid: parentFid,\n            file_name: name,\n            dir_path: '',\n            dir_init_lock: false,\n        });\n        return { status: 'ok', fid: data.fid, name };\n    },\n});\n","sourceCodeStart":4,"sourceCodeEnd":38,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/quark/mkdir.js#L4-L38","documentation":"quark mkdir accepts the target parent either by path (--parent, resolved via findFolder) or directly by id (--parent-fid). Supplying both is ambiguous, so the CLI throws ArgumentError('Cannot use both --parent and --parent-fid') before any API call. Exactly one parent selector must be provided.","triggerScenarios":"Invoking quark mkdir with both flags simultaneously, e.g. `quark mkdir --name x --parent /docs --parent-fid abc123`.","commonSituations":"Copy-pasting an example command that already included --parent-fid and adding --parent yourself; wrapper scripts concatenating flags from config and CLI; migration from fid-based invocations leaving both flags set.","solutions":["Remove one of the two flags — keep --parent-fid if you already know the fid, otherwise keep --parent with the path.","In wrapper scripts, assert only one parent flag is emitted before invoking the CLI.","Resolve the path to a fid yourself once (via findFolder/listing) and standardize on --parent-fid for speed and determinism."],"exampleFix":"// before\nquark mkdir --name reports --parent /docs --parent-fid fid_123\n// after\nquark mkdir --name reports --parent-fid fid_123","handlingStrategy":"validation","validationCode":"const flags = collectFlags(args);\nif (flags.includes('--parent') && flags.includes('--parent-fid')) {\n  throw new Error('Choose either --parent (path) or --parent-fid, not both');\n}","typeGuard":"function hasExactlyOneParentSelector(opts) {\n  return Boolean(opts.parent) !== Boolean(opts['parent-fid']);\n}","tryCatchPattern":"try {\n  await run(['quark', 'mkdir', '--name', name, ...parentFlags]);\n} catch (e) {\n  if (/Cannot use both --parent and --parent-fid/.test(String(e.message))) {\n    console.error('Remove one of --parent / --parent-fid and retry.');\n  } else throw e;\n}","preventionTips":["Standardize on one parent selector style across your scripts","Resolve paths to fids once and use --parent-fid thereafter","In wrappers, emit parent flags from a single config source","Add a pre-invocation assert that only one parent flag is present"],"tags":["argument-validation","quark","mkdir","cli","mutually-exclusive-flags"],"backgroundTag":"mutually-exclusive-arguments","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}