{"record":{"id":"952f625f198a5f33","repo":"jackwener/OpenCLI","slug":"new-name-cannot-be-empty","errorCode":null,"errorMessage":"New name cannot be empty","messagePattern":"New name cannot be empty","errorType":"validation","errorClass":"ArgumentError","httpStatus":null,"severity":"error","filePath":"clis/quark/rename.js","lineNumber":20,"sourceCode":"import { cli, Strategy } from '@jackwener/opencli/registry';\nimport { DRIVE_API, apiPost } from './utils.js';\ncli({\n    site: 'quark',\n    name: 'rename',\n    access: 'write',\n    description: 'Rename a file in your Quark Drive',\n    domain: 'pan.quark.cn',\n    strategy: Strategy.COOKIE,\n    defaultFormat: 'json',\n    args: [\n        { name: 'fid', required: true, positional: true, help: 'File ID to rename' },\n        { name: 'name', required: true, help: 'New file name' },\n    ],\n    func: async (page, kwargs) => {\n        const fid = kwargs.fid;\n        const name = kwargs.name;\n        if (!name.trim())\n            throw new ArgumentError('New name cannot be empty');\n        await apiPost(page, `${DRIVE_API}/rename?pr=ucpro&fr=pc`, {\n            fid,\n            file_name: name,\n        });\n        return { status: 'ok', fid, new_name: name };\n    },\n});\n","sourceCodeStart":2,"sourceCodeEnd":28,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/quark/rename.js#L2-L28","documentation":"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.","triggerScenarios":"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.","commonSituations":"CI scripts interpolating an unset or empty environment variable into --name; accidental double-space or quoted-empty argument; template rendering producing a blank name.","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."],"exampleFix":"// before\nquark rename --fid $FID --name \"$NAME\"\n// after\n[ -n \"$(echo \"$NAME\" | tr -d '[:space:]')\" ] || { echo 'NAME is empty'; exit 1; }\nquark rename --fid $FID --name \"$NAME\"","handlingStrategy":"validation","validationCode":"function isValidNewName(name) {\n  return typeof name === 'string' && name.trim().length > 0;\n}\nif (!isValidNewName(kwargs.name)) throw new Error('Provide a non-empty --name');","typeGuard":"function isNonEmptyString(v) {\n  return typeof v === 'string' && v.trim().length > 0;\n}","tryCatchPattern":null,"preventionTips":["Always quote --name values in shell scripts.","Validate variables are non-blank before interpolation.","Trim user input before passing it as the new name."],"tags":["validation","argument-error","quark"],"backgroundTag":"missing-required-argument","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}