{"record":{"id":"378a6e4d9746fca7","repo":"AlistGo/alist","slug":"new-name-is-empty-378a6e","errorCode":null,"errorMessage":"new name is empty","messagePattern":"new name is empty","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"drivers/yunpan360/driver.go","lineNumber":228,"sourceCode":"\t\treturn cloneObj(srcObj, stdpath.Join(dstDir.GetPath(), srcObj.GetName()), srcObj.GetName()), nil\n\t}\n\tif d.authMode() != authTypeAPIKey {\n\t\treturn nil, errs.NotImplement\n\t}\n\n\tsrcPath := apiPathForObj(srcObj)\n\tdstPath := ensureDirAPIPath(dstDir.GetPath())\n\tif err := d.openMove(ctx, srcPath, dstPath); err != nil {\n\t\treturn nil, err\n\t}\n\treturn cloneObj(srcObj, stdpath.Join(dstDir.GetPath(), srcObj.GetName()), srcObj.GetName()), nil\n}\n\nfunc (d *Yunpan360) Rename(ctx context.Context, srcObj model.Obj, newName string) (model.Obj, error) {\n\tif d.authMode() == authTypeCookie {\n\t\ttargetName := strings.TrimSuffix(strings.TrimSpace(newName), \"/\")\n\t\tif targetName == \"\" {\n\t\t\treturn nil, errors.New(\"new name is empty\")\n\t\t}\n\t\tif err := d.cookieRename(ctx, srcObj, targetName); err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t\tparentPath := stdpath.Dir(srcObj.GetPath())\n\t\tif parentPath == \".\" {\n\t\t\tparentPath = \"/\"\n\t\t}\n\t\treturn cloneObj(srcObj, stdpath.Join(parentPath, targetName), targetName), nil\n\t}\n\tif d.authMode() != authTypeAPIKey {\n\t\treturn nil, errs.NotImplement\n\t}\n\n\tsrcPath := apiPathForObj(srcObj)\n\ttargetName := newName\n\tif srcObj.IsDir() {\n\t\ttargetName = ensureDirSuffix(newName)","sourceCodeStart":210,"sourceCodeEnd":246,"githubUrl":"https://github.com/AlistGo/alist/blob/843d9dc8149126976b2625911e45a4d3ffd6f2f5/drivers/yunpan360/driver.go#L210-L246","documentation":"Thrown by Yunpan360 Rename() in cookie mode when the new name, after TrimSpace and stripping one trailing \"/\", is empty. Renaming to an empty (or slash-only, or whitespace-only) name is meaningless and would break the web API's path semantics, so the driver validates locally before calling cookieRename.","triggerScenarios":"Calling Rename with newName = \"\", \" \", \"/\", or \"//\"; UI layers that pass the raw input of a rename dialog without validating; scripts deriving new names from templates that render empty.","commonSituations":"Rename dialog submitted with an empty field; automated bulk renames where a pattern produces an empty string for some rows; trailing-slash inputs for folder names getting collapsed to empty.","solutions":["Validate the new name client-side before calling Rename (non-empty after trimming slashes/spaces)","Fix the rename template/script that produced an empty name","Preserve the extension logic — strip only the name's illegal characters, not the whole name"],"exampleFix":"// before\nnewObj, err := d.Rename(ctx, srcObj, newName)\n\n// after\nname := strings.TrimSuffix(strings.TrimSpace(newName), \"/\")\nif name == \"\" {\n    return nil, errors.New(\"new name must not be empty\")\n}\nnewObj, err := d.Rename(ctx, srcObj, name)","handlingStrategy":"validation","validationCode":"name := strings.TrimSuffix(strings.TrimSpace(newName), \"/\")\nif name == \"\" {\n    return nil, errors.New(\"new name must not be empty\")\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Validate rename input in the UI layer before submitting","Guard bulk-rename templates against empty rendered names","Reject whitespace-only and slash-only inputs client-side"],"tags":["yunpan360","driver","rename","validation","cookie"],"backgroundTag":null,"analyzedSha":"843d9dc8149126976b2625911e45a4d3ffd6f2f5","analyzedAt":"2026-08-15T12:14:11.722Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}