AlistGo/alist · error

missing object path

Error message

missing object path

What it means

Guard at the top of cookieRename: renaming via the cookie API needs the object's current remote path for the 'path' form field. If normalizeRemotePath(srcObj.GetPath()) is empty, the rename is aborted (drivers/yunpan360/util.go:373).

Solutions

  1. Pass an object obtained from List() so Path is populated correctly
  2. Ensure Path is the CURRENT full remote path, not the desired new name
  3. Re-list the parent directory and retry with the fresh object

Example fix

// before
err := d.Rename(ctx, &model.Object{ID: "123", Name: "old.txt"}, "new.txt")

// after
objs, _ := d.List(ctx, dir)
var target model.Obj
for _, o := range objs { if o.GetName() == "old.txt" { target = o } }
err := d.Rename(ctx, target, "new.txt")
Defensive patterns

Strategy: validation

Validate before calling

if normalizeRemotePath(srcObj.GetPath()) == "" { return errors.New("cannot rename: source path missing") }

Type guard

func canRename(obj model.Obj) bool { return normalizeRemotePath(obj.GetPath()) != "" && strings.TrimSpace(obj.GetID()) != "" }

Try / catch

if !canRename(srcObj) { return errors.New("refresh listing before rename") }
return d.cookieRename(ctx, srcObj, newName)

Prevention

When it happens

Trigger: Calling Rename with an object whose Path is empty/unnormalized. Commonly when caller code constructs the object from name+parent incorrectly, or the path field was never populated during object creation.

Common situations: Renaming right after building an object from a search/other index that lacks paths; path field omitted in object mapping code; passing the new name in Path instead of the current path.

Related errors


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

Appendix: source

Thrown at drivers/yunpan360/util.go:373

	}

	var resp CookieDownloadResp
	err = d.cookieRequestForm(ctx, downloadPath, map[string]string{
		"nid":       nid,
		"fname":     fname,
		"owner_qid": ownerQID,
		"token":     token,
	}, &resp)
	if err != nil {
		return nil, err
	}
	return &resp, nil
}

func (d *Yunpan360) cookieRename(ctx context.Context, srcObj model.Obj, newName string) error {
	path := normalizeRemotePath(srcObj.GetPath())
	if path == "" {
		return errors.New("missing object path")
	}
	nid := strings.TrimSpace(srcObj.GetID())
	if nid == "" {
		return errors.New("missing object id")
	}

	ownerQID, err := d.resolveCookieOwnerQID(ctx, srcObj, false)
	if err != nil {
		return err
	}

	return d.cookieRequestForm(ctx, "/file/rename", map[string]string{
		"path":      path,
		"nid":       nid,
		"newpath":   strings.TrimSuffix(strings.TrimSpace(newName), "/"),
		"owner_qid": ownerQID,
	}, nil)
}

View on GitHub (pinned to 843d9dc814)