{"record":{"id":"544b5458b07ebfc7","repo":"AlistGo/alist","slug":"missing-object-path","errorCode":null,"errorMessage":"missing object path","messagePattern":"missing object path","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"drivers/yunpan360/util.go","lineNumber":373,"sourceCode":"\t}\n\n\tvar resp CookieDownloadResp\n\terr = d.cookieRequestForm(ctx, downloadPath, map[string]string{\n\t\t\"nid\":       nid,\n\t\t\"fname\":     fname,\n\t\t\"owner_qid\": ownerQID,\n\t\t\"token\":     token,\n\t}, &resp)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn &resp, nil\n}\n\nfunc (d *Yunpan360) cookieRename(ctx context.Context, srcObj model.Obj, newName string) error {\n\tpath := normalizeRemotePath(srcObj.GetPath())\n\tif path == \"\" {\n\t\treturn errors.New(\"missing object path\")\n\t}\n\tnid := strings.TrimSpace(srcObj.GetID())\n\tif nid == \"\" {\n\t\treturn errors.New(\"missing object id\")\n\t}\n\n\townerQID, err := d.resolveCookieOwnerQID(ctx, srcObj, false)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\treturn d.cookieRequestForm(ctx, \"/file/rename\", map[string]string{\n\t\t\"path\":      path,\n\t\t\"nid\":       nid,\n\t\t\"newpath\":   strings.TrimSuffix(strings.TrimSpace(newName), \"/\"),\n\t\t\"owner_qid\": ownerQID,\n\t}, nil)\n}","sourceCodeStart":355,"sourceCodeEnd":391,"githubUrl":"https://github.com/AlistGo/alist/blob/843d9dc8149126976b2625911e45a4d3ffd6f2f5/drivers/yunpan360/util.go#L355-L391","documentation":"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).","triggerScenarios":"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.","commonSituations":"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.","solutions":["Pass an object obtained from List() so Path is populated correctly","Ensure Path is the CURRENT full remote path, not the desired new name","Re-list the parent directory and retry with the fresh object"],"exampleFix":"// before\nerr := d.Rename(ctx, &model.Object{ID: \"123\", Name: \"old.txt\"}, \"new.txt\")\n\n// after\nobjs, _ := d.List(ctx, dir)\nvar target model.Obj\nfor _, o := range objs { if o.GetName() == \"old.txt\" { target = o } }\nerr := d.Rename(ctx, target, \"new.txt\")","handlingStrategy":"validation","validationCode":"if normalizeRemotePath(srcObj.GetPath()) == \"\" { return errors.New(\"cannot rename: source path missing\") }","typeGuard":"func canRename(obj model.Obj) bool { return normalizeRemotePath(obj.GetPath()) != \"\" && strings.TrimSpace(obj.GetID()) != \"\" }","tryCatchPattern":"if !canRename(srcObj) { return errors.New(\"refresh listing before rename\") }\nreturn d.cookieRename(ctx, srcObj, newName)","preventionTips":["Pass listing-derived objects to rename","Keep Path = current location, Name = current name; never the desired new name","Disable rename in the UI when the object is synthetic/root"],"tags":["yunpan360","validation","rename","go"],"backgroundTag":null,"analyzedSha":"843d9dc8149126976b2625911e45a4d3ffd6f2f5","analyzedAt":"2026-08-15T12:14:11.722Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}