AlistGo/alist · warning
new name is empty
Error message
new name is empty
What it means
GuangYaPan Rename validates the new name after trimming and rejects empty values before calling /file/rename. This prevents sending the API a request that would blank out the file's name or fail server-side with a confusing message.
Source
Thrown at drivers/guangyapan/driver.go:277
}
if !strings.EqualFold(strings.TrimSpace(out.Msg), "success") {
return fmt.Errorf("make dir failed: %s", strings.TrimSpace(out.Msg))
}
return nil
}
func (d *GuangYaPan) Rename(ctx context.Context, srcObj model.Obj, newName string) error {
if err := d.ensureAccessToken(ctx); err != nil {
return err
}
fileID := strings.TrimSpace(srcObj.GetID())
if fileID == "" {
return errors.New("file id is empty")
}
name := strings.TrimSpace(newName)
if name == "" {
return errors.New("new name is empty")
}
var out commonResp
if err := d.postAPI(ctx, "/nd.bizuserres.s/v1/file/rename", map[string]any{
"fileId": fileID,
"newName": name,
}, &out); err != nil {
return err
}
if !strings.EqualFold(strings.TrimSpace(out.Msg), "success") {
return fmt.Errorf("rename failed: %s", strings.TrimSpace(out.Msg))
}
return nil
}
func (d *GuangYaPan) Remove(ctx context.Context, obj model.Obj) error {
if err := d.ensureAccessToken(ctx); err != nil {
return errView on GitHub (pinned to 843d9dc814)
Solutions
- Require a non-empty trimmed name in the caller/UI before submitting the rename
- Default the dialog to the current name so an accidental blank submit is impossible
- In scripts, assert the new name variable is non-empty
Example fix
// before
d.Rename(ctx, obj, "")
// after
newName := strings.TrimSpace(input)
if newName == "" { return errors.New("new name required") }
d.Rename(ctx, obj, newName) Defensive patterns
Strategy: validation
Validate before calling
newName := strings.TrimSpace(newName)
if newName == "" {
return errors.New("new name is required")
}
return d.Rename(ctx, srcObj, newName) Type guard
func validNewName(s string) bool { return strings.TrimSpace(s) != "" } Prevention
- Pre-fill rename dialogs with the current name
- Validate non-empty trimmed names in form logic
- In batch-rename scripts, skip rows with blank target names
When it happens
Trigger: Renaming with newName that is empty or whitespace-only: UI allowed an empty rename dialog submit, or a script passed an unset variable.
Common situations: Rename dialog submitted without typing; batch rename script with a missing name field; leading/trailing spaces making the trimmed value empty.
Related errors
- file id is empty
- dir name is empty
- offline url is empty
- new name is empty
- login failed: provide a valid access_token, or refresh_token
AI-assisted analysis of AlistGo/alist@843d9dc814 (2026-08-15).
Data as JSON: /api/errors/b781239282c3f0a3.
Report an issue: GitHub.