{"record":{"id":"3c0215256a2af490","repo":"locustio/locust","slug":"no-tasks-defined-on-self-class-name-extr","errorCode":null,"errorMessage":"No tasks defined on {self.__class__.__name__}{extra_message} use the @task decorator or set the 'tasks' attribute of the TaskSet","messagePattern":"No tasks defined on (.+?)(.+?) use the @task decorator or set the 'tasks' attribute of the TaskSet","errorType":"exception","errorClass":"Exception","httpStatus":null,"severity":"error","filePath":"locust/user/task.py","lineNumber":428,"sourceCode":"    def schedule_task(self, task_callable, first=False):\n        \"\"\"\n        Add a task to the User's task execution queue.\n\n        :param task_callable: User task to schedule.\n        :param first: Optional keyword argument. If True, the task will be put first in the queue.\n        \"\"\"\n        if first:\n            self._task_queue.appendleft(task_callable)\n        else:\n            self._task_queue.append(task_callable)\n\n    def get_next_task(self):\n        if not self.tasks:\n            if getattr(self, \"task\", None):\n                extra_message = \", but you have set a 'task' attribute - maybe you meant to set 'tasks'?\"\n            else:\n                extra_message = \".\"\n            raise Exception(\n                f\"No tasks defined on {self.__class__.__name__}{extra_message} use the @task decorator or set the 'tasks' attribute of the TaskSet\"\n            )\n        return random.choice(self.tasks)\n\n    def wait_time(self):\n        \"\"\"\n        Method that returns the time (in seconds) between the execution of tasks.\n\n        Example::\n\n            from locust import TaskSet, between\n            class Tasks(TaskSet):\n                wait_time = between(3, 25)\n        \"\"\"\n        if self.user.wait_time:\n            return self.user.wait_time()\n        elif self.min_wait is not None and self.max_wait is not None:\n            return random.randint(self.min_wait, self.max_wait) / 1000.0","sourceCodeStart":410,"sourceCodeEnd":446,"githubUrl":"https://github.com/locustio/locust/blob/f391a716e12c2c712e80b5835e877b7933397453/locust/user/task.py#L410-L446","documentation":"TaskSet.get_next_task() picks a random task from self.tasks; if the TaskSet has no tasks and no `task` attribute, it cannot proceed and raises. This is raised at runtime when the TaskSet starts running.","triggerScenarios":"Defining a TaskSet subclass with no @task methods and no `tasks` attribute; or setting the singular `task` attribute instead of `tasks` (extra hint message).","commonSituations":"Empty TaskSet skeletons left after refactoring; misspelling `tasks`; forgetting to mark abstract base classes.","solutions":["Add @task-decorated methods to the TaskSet","Set the `tasks` attribute (list of callables or TaskSet classes)","If `task` was set, rename it to `tasks` (plural)","Mark base classes as abstract by not instantiating them directly"],"exampleFix":"// before\nclass MyTaskSet(TaskSet):\n    task = [other_task]  # wrong\n// after\nclass MyTaskSet(TaskSet):\n    tasks = [other_task]","handlingStrategy":"validation","validationCode":"assert getattr(MyTaskSet, 'tasks', None) or any(callable(v) and getattr(v, 'locust_task_weight', None) for v in vars(MyTaskSet).values()), \"TaskSet has no tasks\"","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Give every concrete TaskSet at least one @task method","Use plural `tasks` attribute name","Mark base-only classes abstract in naming/docs"],"tags":["python","locust","taskset","configuration"],"backgroundTag":"no-tasks-defined","analyzedSha":"f391a716e12c2c712e80b5835e877b7933397453","analyzedAt":"2026-08-29T00:36:13.872Z","schemaVersion":2},"datasetVersion":"2026-08-29T02:17:18.158Z"}