{"record":{"id":"589bdbf2e70499c8","repo":"locustio/locust","slug":"no-tasks-defined-on-self-user-class-name","errorCode":null,"errorMessage":"No tasks defined on {self.user.__class__.__name__}{extra_message} Use the @task decorator or set the 'tasks' attribute of the User (or mark it as abstract = True if you only intend to subclass it)","messagePattern":"No tasks defined on (.+?)(.+?) Use the @task decorator or set the 'tasks' attribute of the User \\(or mark it as abstract = True if you only intend to subclass it\\)","errorType":"exception","errorClass":"Exception","httpStatus":null,"severity":"error","filePath":"locust/user/task.py","lineNumber":502,"sourceCode":"        \"\"\"\n        Shortcut to the client :py:attr:`client <locust.User.client>` attribute of this TaskSet's :py:class:`User <locust.User>`\n        \"\"\"\n        return self.user.client\n\n\nclass DefaultTaskSet(TaskSet):\n    \"\"\"\n    Default root TaskSet that executes tasks in User.tasks.\n    It executes tasks declared directly on the Locust with the user instance as the task argument.\n    \"\"\"\n\n    def get_next_task(self):\n        if not self.user.tasks:\n            if getattr(self.user, \"task\", None):\n                extra_message = \", but you have set a 'task' attribute on your class - maybe you meant to set 'tasks'?\"\n            else:\n                extra_message = \".\"\n            raise Exception(\n                f\"No tasks defined on {self.user.__class__.__name__}{extra_message} Use the @task decorator or set the 'tasks' attribute of the User (or mark it as abstract = True if you only intend to subclass it)\"\n            )\n        return random.choice(self.user.tasks)\n\n    def execute_task(self, task):\n        if hasattr(task, \"tasks\") and issubclass(task, TaskSet):\n            # task is  (nested) TaskSet class\n            task(self.user).run()\n        else:\n            # task is a function\n            task(self.user)\n","sourceCodeStart":484,"sourceCodeEnd":514,"githubUrl":"https://github.com/locustio/locust/blob/f391a716e12c2c712e80b5835e877b7933397453/locust/user/task.py#L484-L514","documentation":"User.get_next_task() (for User-based, non-TaskSet users) requires the User class to have tasks. If the User has no tasks and no `task` attribute, it raises, suggesting @task or the tasks attribute, or marking the class abstract.","triggerScenarios":"Running a User subclass with no @task methods and no `tasks` list; or setting singular `task` instead of `tasks`.","commonSituations":"Instantiating base/shared User classes intended only for subclassing; refactoring removed all tasks; typo `task = [...]`.","solutions":["Add @task-decorated methods to the User","Set `tasks = [...]` on the User","Fix `task` to `tasks` if the singular attribute was set","Set `abstract = True` on User classes meant only as base classes"],"exampleFix":"// before\nclass MyBaseUser(User):\n    task = [do_thing]\n// after\nclass MyBaseUser(User):\n    abstract = True\nclass MyUser(MyBaseUser):\n    tasks = [do_thing]","handlingStrategy":"validation","validationCode":"assert getattr(MyUser, 'tasks', None) or getattr(MyUser, 'abstract', False) or any(callable(v) and getattr(v, 'locust_task_weight', None) for v in vars(MyUser).values()), \"User has no tasks\"","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Set abstract = True on base User classes","Use plural `tasks` attribute","Ensure every runnable User has @task methods"],"tags":["python","locust","user","configuration"],"backgroundTag":"no-tasks-defined","analyzedSha":"f391a716e12c2c712e80b5835e877b7933397453","analyzedAt":"2026-08-29T00:36:13.872Z","schemaVersion":2},"datasetVersion":"2026-08-29T02:17:18.158Z"}