AlistGo/alist · error

new name is empty

Error message

new name is empty

What it means

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.

Source

Thrown at drivers/yunpan360/driver.go:228

		return cloneObj(srcObj, stdpath.Join(dstDir.GetPath(), srcObj.GetName()), srcObj.GetName()), nil
	}
	if d.authMode() != authTypeAPIKey {
		return nil, errs.NotImplement
	}

	srcPath := apiPathForObj(srcObj)
	dstPath := ensureDirAPIPath(dstDir.GetPath())
	if err := d.openMove(ctx, srcPath, dstPath); err != nil {
		return nil, err
	}
	return cloneObj(srcObj, stdpath.Join(dstDir.GetPath(), srcObj.GetName()), srcObj.GetName()), nil
}

func (d *Yunpan360) Rename(ctx context.Context, srcObj model.Obj, newName string) (model.Obj, error) {
	if d.authMode() == authTypeCookie {
		targetName := strings.TrimSuffix(strings.TrimSpace(newName), "/")
		if targetName == "" {
			return nil, errors.New("new name is empty")
		}
		if err := d.cookieRename(ctx, srcObj, targetName); err != nil {
			return nil, err
		}
		parentPath := stdpath.Dir(srcObj.GetPath())
		if parentPath == "." {
			parentPath = "/"
		}
		return cloneObj(srcObj, stdpath.Join(parentPath, targetName), targetName), nil
	}
	if d.authMode() != authTypeAPIKey {
		return nil, errs.NotImplement
	}

	srcPath := apiPathForObj(srcObj)
	targetName := newName
	if srcObj.IsDir() {
		targetName = ensureDirSuffix(newName)

View on GitHub (pinned to 843d9dc814)

Solutions

  1. Validate the new name client-side before calling Rename (non-empty after trimming slashes/spaces)
  2. Fix the rename template/script that produced an empty name
  3. Preserve the extension logic — strip only the name's illegal characters, not the whole name

Example fix

// before
newObj, err := d.Rename(ctx, srcObj, newName)

// after
name := strings.TrimSuffix(strings.TrimSpace(newName), "/")
if name == "" {
    return nil, errors.New("new name must not be empty")
}
newObj, err := d.Rename(ctx, srcObj, name)
Defensive patterns

Strategy: validation

Validate before calling

name := strings.TrimSuffix(strings.TrimSpace(newName), "/")
if name == "" {
    return nil, errors.New("new name must not be empty")
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of AlistGo/alist@843d9dc814 (2026-08-15). Data as JSON: /api/errors/378a6e4d9746fca7. Report an issue: GitHub.