jackwener/OpenCLI · error · ArgumentError
Folder name cannot be empty
Error message
Folder name cannot be empty
What it means
clis/quark/mkdir.js validates the --name argument before creating a folder on Quark drive. If the name is missing or only whitespace (name.trim() is empty), it throws ArgumentError('Folder name cannot be empty'). Quark's API would reject an empty name, so the CLI fails fast with a clear message.
Source
Thrown at clis/quark/mkdir.js:20
import { cli, Strategy } from '@jackwener/opencli/registry';
import { DRIVE_API, apiPost, findFolder } from './utils.js';
cli({
site: 'quark',
name: 'mkdir',
access: 'write',
description: 'Create a folder in your Quark Drive',
domain: 'pan.quark.cn',
strategy: Strategy.COOKIE,
defaultFormat: 'json',
args: [
{ name: 'name', required: true, positional: true, help: 'Folder name' },
{ name: 'parent', help: 'Parent folder path (resolved by name)' },
{ name: 'parent-fid', help: 'Parent folder fid (use directly)' },
],
func: async (page, kwargs) => {
const name = kwargs.name;
if (!name.trim())
throw new ArgumentError('Folder name cannot be empty');
if (kwargs.parent && kwargs['parent-fid']) {
throw new ArgumentError('Cannot use both --parent and --parent-fid');
}
const parentFid = kwargs['parent-fid']
? kwargs['parent-fid']
: kwargs.parent
? await findFolder(page, kwargs.parent)
: '0';
const data = await apiPost(page, `${DRIVE_API}?pr=ucpro&fr=pc`, {
pdir_fid: parentFid,
file_name: name,
dir_path: '',
dir_init_lock: false,
});
return { status: 'ok', fid: data.fid, name };
},
});
View on GitHub (pinned to 49907e53dc)
Solutions
- Pass a non-empty --name value, e.g. `quark mkdir --name backups`.
- In scripts, guard the variable before calling: [ -n "$FOLDER" ] || exit 1.
- Check quoting so spaces in the name survive shell parsing.
- If deriving the name dynamically, default it (e.g. use a date-stamped name) when the source is empty.
Example fix
// before
const name = kwargs.name;
if (!name.trim()) throw new ArgumentError('Folder name cannot be empty');
// after (caller side)
const name = (kwargs.name ?? '').trim();
if (!name) throw new ArgumentError('Folder name cannot be empty (got empty --name)'); Defensive patterns
Strategy: validation
Validate before calling
const name = (process.argv[/* --name value */] ?? '').trim();
if (!name) throw new Error('Provide a non-empty --name for quark mkdir'); Type guard
function isValidFolderName(n) {
return typeof n === 'string' && n.trim().length > 0;
} Try / catch
try {
await run(['quark', 'mkdir', '--name', name]);
} catch (e) {
if (/Folder name cannot be empty/.test(String(e.message))) {
console.error('Fix the --name argument; it was empty or whitespace.');
process.exitCode = 2;
} else throw e;
} Prevention
- Always trim and check CLI-supplied names before invoking
- Guard shell variables: require non-empty env/params in scripts
- Quote arguments so spaces and whitespace survive the shell
- Fail fast in CI when interpolated names resolve to empty
When it happens
Trigger: Running the quark mkdir command with no --name value, an empty string, or a name consisting solely of spaces, e.g. `quark mkdir --name " "`.
Common situations: Shell variable holding the folder name was empty/unset; quoting mistake passing only spaces; scripting typo dropping the --name flag; CI pipeline interpolating an empty env var.
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
- Cannot use both --parent and --parent-fid
- No fids provided
- Either --to or --to-fid is required
- Cannot use both --to and --to-fid
- <train-no> "${trainNo}" does not look like a 12306 internal
AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29).
Data as JSON: /api/errors/b37b5c67d748d0e4.
Report an issue: GitHub.