{"record":{"id":"19a13f3238b93ece","repo":"locustio/locust","slug":"there-are-no-users-with-weight-0","errorCode":null,"errorMessage":"There are no users with weight > 0.","messagePattern":"There are no users with weight > 0\\.","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"locust/env.py","lineNumber":267,"sourceCode":"        else:\n            exclude_tags = None\n\n        for user_class in self.user_classes:\n            filter_tasks_by_tags(user_class, tags, exclude_tags)\n\n    def _remove_user_classes_with_weight_zero(self) -> None:\n        \"\"\"\n        Remove user classes having a weight of zero.\n        \"\"\"\n        if len(self.user_classes) == 0:\n            # Preserve previous behaviour that allowed no user classes to be specified.\n            return\n        filtered_user_classes = [\n            user_class for user_class in self.user_classes if user_class.weight > 0 or user_class.fixed_count > 0\n        ]\n        if len(filtered_user_classes) == 0:\n            # TODO: Better exception than `ValueError`?\n            raise ValueError(\"There are no users with weight > 0.\")\n        self.user_classes[:] = filtered_user_classes\n\n    def assign_equal_weights(self) -> None:\n        \"\"\"\n        Update the user classes such that each user runs their specified tasks with equal\n        probability.\n        \"\"\"\n        for u in self.user_classes:\n            u.weight = 1\n            user_tasks: list[TaskSet | Callable] = []\n            tasks_frontier = u.tasks\n            while len(tasks_frontier) != 0:\n                t = tasks_frontier.pop()\n                if isinstance(t, TaskHolder):\n                    tasks_frontier.extend(t.tasks)\n                elif callable(t):\n                    if t not in user_tasks:\n                        user_tasks.append(t)","sourceCodeStart":249,"sourceCodeEnd":285,"githubUrl":"https://github.com/locustio/locust/blob/f391a716e12c2c712e80b5835e877b7933397453/locust/env.py#L249-L285","documentation":"Environment filters out user classes whose weight is 0 (and fixed_count 0). If filtering removes every user class, no load can be generated, so it raises ValueError (noted in source as needing a better exception type).","triggerScenarios":"Setting `weight = 0` on all user classes passed to Environment(user_classes=[...]); passing an empty list of user classes where all get filtered; dynamically zeroing weights via config to 'disable' the only user class.","commonSituations":"Driving user weights from a config file where all weights resolve to 0; disabling a single-class test by setting weight 0; typos in config keys so weight defaults are lost.","solutions":["Give at least one user class a weight > 0 (or a fixed_count > 0)","If a class should be excluded, keep another active class in the list","Validate weights before constructing Environment"],"exampleFix":"// before\nenv = Environment(user_classes=[UserA])  # UserA.weight = 0\n// after\nUserA.weight = 1\nenv = Environment(user_classes=[UserA])","handlingStrategy":"validation","validationCode":"classes = [UserA, UserB]\nassert any(getattr(c, \"weight\", 1) > 0 or getattr(c, \"fixed_count\", 0) > 0 for c in classes), \"need at least one user with weight > 0\"\nenv = Environment(user_classes=classes)","typeGuard":null,"tryCatchPattern":"try:\n    env = Environment(user_classes=classes)\nexcept ValueError as e:\n    if \"no users with weight\" in str(e):\n        raise RuntimeError(\"Enable at least one user class (weight > 0)\") from e\n    raise","preventionTips":["Never set weight=0 on every class in a run","Sanity-check config-driven weights before constructing Environment","Keep at least one default active class"],"tags":["configuration","users","weights"],"backgroundTag":"empty-user-configuration","analyzedSha":"f391a716e12c2c712e80b5835e877b7933397453","analyzedAt":"2026-08-29T00:36:13.872Z","schemaVersion":2},"datasetVersion":"2026-08-29T02:17:18.158Z"}