{"record":{"id":"99cb7e8bd91977d2","repo":"locustio/locust","slug":"no-tasks-defined-use-the-task-decorator-or-set-t","errorCode":null,"errorMessage":"No tasks defined. Use the @task decorator or set the 'tasks' attribute of the SequentialTaskSet","messagePattern":"No tasks defined\\. Use the @task decorator or set the 'tasks' attribute of the SequentialTaskSet","errorType":"exception","errorClass":"LocustError","httpStatus":null,"severity":"error","filePath":"locust/user/sequential_taskset.py","lineNumber":63,"sourceCode":"class SequentialTaskSet(TaskSet, metaclass=SequentialTaskSetMeta):\n    \"\"\"\n    Class defining a sequence of tasks that a User will execute.\n\n    Works like TaskSet, but task weight is ignored, and all tasks are executed in order. Tasks can\n    either be specified by setting the *tasks* attribute to a list of tasks, or by declaring tasks\n    as methods using the @task decorator. The order of declaration decides the order of execution.\n\n    It's possible to combine a task list in the *tasks* attribute, with some tasks declared using\n    the @task decorator. The order of declaration is respected also in that case.\n    \"\"\"\n\n    def __init__(self, *args, **kwargs):\n        super().__init__(*args, **kwargs)\n        self._task_cycle = cycle(self.tasks)\n\n    def get_next_task(self):\n        if not self.tasks:\n            raise LocustError(\n                \"No tasks defined. Use the @task decorator or set the 'tasks' attribute of the SequentialTaskSet\"\n            )\n        return next(self._task_cycle)\n","sourceCodeStart":45,"sourceCodeEnd":67,"githubUrl":"https://github.com/locustio/locust/blob/f391a716e12c2c712e80b5835e877b7933397453/locust/user/sequential_taskset.py#L45-L67","documentation":"SequentialTaskSet.get_next_task() cycles through self.tasks in order; if the tasks list is empty there is nothing to cycle, so it raises LocustError with guidance to define tasks via @task or the tasks attribute.","triggerScenarios":"Instantiating a SequentialTaskSet subclass with no @task methods and no tasks attribute (or an empty list), then the runner calls get_next_task() when executing the user.","commonSituations":"Empty placeholder TaskSet classes; tasks defined only on a base class in a way Locust doesn't pick up; conditional task registration that ended up empty; typos like assigning 'task' instead of 'tasks'.","solutions":["Add at least one @task decorated method to the SequentialTaskSet class","Or set the 'tasks' attribute to a non-empty list of task callables/classes","Verify the class you're running is the one with tasks defined (check inheritance and that tasks aren't filtered out by tags at runtime)"],"exampleFix":"// before\nclass MyFlow(SequentialTaskSet):\n    pass\n// after\nclass MyFlow(SequentialTaskSet):\n    @task\n    def step_one(self):\n        self.client.get(\"/\")","handlingStrategy":"validation","validationCode":"if not getattr(MyFlow, \"tasks\", None):\n    raise RuntimeError(\"SequentialTaskSet has no tasks defined\")","typeGuard":"def has_tasks(cls) -> bool:\n    return bool(getattr(cls, \"tasks\", None)) or any(hasattr(v, \"locust_task_weight\") for v in vars(cls).values())","tryCatchPattern":"try:\n    flow = MyFlow(user)\nexcept LocustError as e:\n    if \"No tasks defined\" in str(e):\n        logging.error(f\"{type(flow).__name__} lacks tasks\")\n    raise","preventionTips":["Give every TaskSet/SequentialTaskSet at least one @task method","Check spelling of the 'tasks' attribute","Instantiate task classes in CI smoke tests to catch empty definitions early"],"tags":["locust","sequential-taskset","task-definition","no-tasks"],"backgroundTag":"no-tasks-defined","analyzedSha":"f391a716e12c2c712e80b5835e877b7933397453","analyzedAt":"2026-08-29T00:36:13.872Z","schemaVersion":2},"datasetVersion":"2026-08-29T02:17:18.158Z"}