{"record":{"id":"6aa4c74a60c71c52","repo":"microsoft/qlib","slug":"cannot-find-user-data","errorCode":null,"errorMessage":"Cannot find user data {}","messagePattern":"Cannot find user data (.+?)","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"qlib/contrib/online/manager.py","lineNumber":144,"sourceCode":"        # save user\n        user_path.mkdir()\n        save_instance(model, self.data_path / user_id / \"model_{}.pickle\".format(user_id))\n        save_instance(strategy, self.data_path / user_id / \"strategy_{}.pickle\".format(user_id))\n        trade_account.save_account(self.data_path / user_id)\n        user_record = pd.read_csv(self.users_file, index_col=0)\n        user_record.loc[user_id] = [add_date]\n        user_record.to_csv(self.users_file)\n\n    def remove_user(self, user_id):\n        \"\"\"\n        remove user {user_id} in current user dataset\n        will delete the folder \"{user_id}\" in user data path\n            :param\n                user_id : string\n        \"\"\"\n        user_path = self.data_path / user_id\n        if not user_path.exists():\n            raise ValueError(\"Cannot find user data {}\".format(user_id))\n        shutil.rmtree(user_path)\n        user_record = pd.read_csv(self.users_file, index_col=0)\n        user_record.drop([user_id], inplace=True)\n        user_record.to_csv(self.users_file)\n","sourceCodeStart":126,"sourceCodeEnd":149,"githubUrl":"https://github.com/microsoft/qlib/blob/79633dd9506ea689e5400dea0197717b5b3d74b7/qlib/contrib/online/manager.py#L126-L149","documentation":"Raised by UserManager.remove_user when the folder data_path/user_id does not exist. remove_user deletes the user's account directory and drops the id from the users record CSV, so it requires the directory to be present.","triggerScenarios":"Calling remove_user with a typo'd or never-created user_id; calling remove twice (the second call finds no folder); the folder was manually deleted but the id remained in users_file.","commonSituations":"Cleanup scripts run after someone already removed the folder by hand; retries after a partially completed removal; mismatch between the users_file CSV contents and the actual folders on disk.","solutions":["Check existence first: if (um.data_path / user_id).exists(): um.remove_user(user_id).","List the actual user folders (iterate um.data_path.iterdir()) to see valid ids before removing.","If the CSV record is out of sync with disk, repair users_file manually so load/remove agree."],"exampleFix":"# before\num.remove_user(\"u1\")  # ValueError: Cannot find user data u1\n\n# after\nif (um.data_path / \"u1\").exists():\n    um.remove_user(\"u1\")","handlingStrategy":"validation","validationCode":"if (um.data_path / user_id).exists():\n    um.remove_user(user_id)","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Guard removals with an existence check so cleanup is idempotent.","Keep users_file CSV in sync with folders: never delete folders by hand.","Log which ids exist before batch cleanup."],"tags":["qlib","online-manager","user","file-not-found","idempotency"],"backgroundTag":null,"analyzedSha":"79633dd9506ea689e5400dea0197717b5b3d74b7","analyzedAt":"2026-08-15T07:01:27.511Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}