AlistGo/alist · error

missing object id

Error message

missing object id

What it means

Guard in cookieRename: the /file/rename form requires nid, so the source object must carry a non-empty ID. If srcObj.GetID() is blank, the rename is rejected (drivers/yunpan360/util.go:377).

Source

Thrown at drivers/yunpan360/util.go:377

		"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)
}

func (d *Yunpan360) resolveCookieDownloadParams(ctx context.Context, file model.Obj, refresh bool) (string, string, error) {
	ownerQID := sanitizeOwnerQID(d.OwnerQID)
	token := strings.TrimSpace(d.DownloadToken)

View on GitHub (pinned to 843d9dc814)

Solutions

  1. Use objects returned by the driver's List (they always carry nid)
  2. If building objects manually, set ID from the listing that produced the path
  3. Refuse rename operations on the root "/" object in caller code

Example fix

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

// after
obj := &model.Object{Path: "/docs/old.txt", ID: "888000111", Name: "old.txt"}
err := d.Rename(ctx, obj, "new.txt")
Defensive patterns

Strategy: validation

Validate before calling

if strings.TrimSpace(srcObj.GetID()) == "" { return errors.New("cannot rename: object id missing") }

Type guard

func hasObjectID(obj model.Obj) bool { return strings.TrimSpace(obj.GetID()) != "" }

Try / catch

if !hasObjectID(srcObj) { srcObj = relistParentFor(srcObj) }
return d.cookieRename(ctx, srcObj, newName)

Prevention

When it happens

Trigger: Renaming an object that has Path but no ID — e.g. a synthetic root folder object, or an object built by caller code that only filled Path/Name.

Common situations: Root directory objects (no nid) passed to rename; object created from a path string without listing; ID lost in a struct copy or JSON marshal/unmarshal.

Related errors


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