jackwener/OpenCLI · error · ArgumentError
New name cannot be empty
Error message
New name cannot be empty
What it means
Thrown by clis/quark/rename.js when the required --name argument is supplied but consists only of whitespace (name.trim() is empty). It is an ArgumentError guarding the Quark rename API, which requires a non-empty file_name. The rename request is never sent.
Source
Thrown at clis/quark/rename.js:20
import { cli, Strategy } from '@jackwener/opencli/registry';
import { DRIVE_API, apiPost } from './utils.js';
cli({
site: 'quark',
name: 'rename',
access: 'write',
description: 'Rename a file in your Quark Drive',
domain: 'pan.quark.cn',
strategy: Strategy.COOKIE,
defaultFormat: 'json',
args: [
{ name: 'fid', required: true, positional: true, help: 'File ID to rename' },
{ name: 'name', required: true, help: 'New file name' },
],
func: async (page, kwargs) => {
const fid = kwargs.fid;
const name = kwargs.name;
if (!name.trim())
throw new ArgumentError('New name cannot be empty');
await apiPost(page, `${DRIVE_API}/rename?pr=ucpro&fr=pc`, {
fid,
file_name: name,
});
return { status: 'ok', fid, new_name: name };
},
});
View on GitHub (pinned to 49907e53dc)
Solutions
- Provide a non-empty new name: quark rename --fid <fid> --name "new-name.ext".
- If the name comes from a variable, check it is non-blank before invoking the command.
- Trim and validate the desired name in the calling script before passing it.
Example fix
// before
quark rename --fid $FID --name "$NAME"
// after
[ -n "$(echo "$NAME" | tr -d '[:space:]')" ] || { echo 'NAME is empty'; exit 1; }
quark rename --fid $FID --name "$NAME" Defensive patterns
Strategy: validation
Validate before calling
function isValidNewName(name) {
return typeof name === 'string' && name.trim().length > 0;
}
if (!isValidNewName(kwargs.name)) throw new Error('Provide a non-empty --name'); Type guard
function isNonEmptyString(v) {
return typeof v === 'string' && v.trim().length > 0;
} Prevention
- Always quote --name values in shell scripts.
- Validate variables are non-blank before interpolation.
- Trim user input before passing it as the new name.
When it happens
Trigger: Running the rename command with --name "" or --name " " (quotes-only or whitespace value); scripts passing an empty variable as the new name; shell quoting that collapses the intended name to empty.
Common situations: CI scripts interpolating an unset or empty environment variable into --name; accidental double-space or quoted-empty argument; template rendering producing a blank name.
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
- No fids provided
- Either --to or --to-fid is required
- Cannot use both --to and --to-fid
- --stoken is required when using --fids
- Invalid Quark share URL: ${url}
AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29).
Data as JSON: /api/errors/952f625f198a5f33.
Report an issue: GitHub.