{"record":{"id":"07d844876d243d5b","repo":"locustio/locust","slug":"tags-are-unsupported-for-markovtaskset-since-they","errorCode":null,"errorMessage":"Tags are unsupported for MarkovTaskSet since they can make the markov chain invalid. Tags detected on {classname}.{task.__name__}: {task.locust_tag_set}","messagePattern":"Tags are unsupported for MarkovTaskSet since they can make the markov chain invalid\\. Tags detected on (.+?)\\.(.+?): (.+?)","errorType":"validation","errorClass":"MarkovTaskTagError","httpStatus":null,"severity":"error","filePath":"locust/user/markov_taskset.py","lineNumber":229,"sourceCode":"    if len(unreachable) > 0:\n        logging.warning(f\"The following markov tasks are unreachable in class {classname}: {unreachable}\")\n\n    return tasks\n\n\ndef validate_no_tags(task, classname: str):\n    \"\"\"\n    Validates that Markov tasks don't have tags, which are unsupported.\n\n    Tags are not supported for MarkovTaskSet because they can make the Markov chain invalid\n    by potentially filtering out tasks that are part of the chain.\n\n    :param task: The task to validate\n    :param classname: Name of the class being validated (for error messages)\n    :raises MarkovTaskTagError: If the task has tags\n    \"\"\"\n    if \"locust_tag_set\" in dir(task):\n        raise MarkovTaskTagError(\n            \"Tags are unsupported for MarkovTaskSet since they can make the markov chain invalid. \"\n            + f\"Tags detected on {classname}.{task.__name__}: {task.locust_tag_set}\"\n        )\n\n\ndef validate_task_name(decorated_func):\n    \"\"\"\n    Validates that certain method names aren't used as Markov tasks.\n\n    This function checks for special method names that shouldn't be used as Markov tasks:\n    - \"on_stop\" and \"on_start\": Using these as Markov tasks will cause them to be called\n      both as tasks AND on stop/start, which is usually not what the user intended.\n    - \"run\": This method is used internally by Locust and must not be overridden or\n      annotated with transitions.\n\n    :param decorated_func: The function to validate\n    :raises Exception: If the function name is \"run\"\n    \"\"\"","sourceCodeStart":211,"sourceCodeEnd":247,"githubUrl":"https://github.com/locustio/locust/blob/f391a716e12c2c712e80b5835e877b7933397453/locust/user/markov_taskset.py#L211-L247","documentation":"Tags would let runs select/reject individual states, which can remove nodes from the Markov chain and invalidate transition probabilities. validate_no_tags raises MarkovTaskTagError if any task in a MarkovTaskSet carries @tag/@tags (detected via the locust_tag_set attribute).","triggerScenarios":"Applying @tag(\"smoke\") or @tags([...]) to a @task method inside a MarkovTaskSet class, then running/validating the class.","commonSituations":"Copy-pasting tagged tasks from a regular TaskSet into a MarkovTaskSet; using tags to subset a smoke-test run on a Markov flow; mixed TaskSet/MarkovTaskSet codebases applying tags uniformly.","solutions":["Remove @tag/@tags decorators from all tasks in MarkovTaskSet classes","If you need to subset runs, split the Markov chain into separate MarkovTaskSet classes instead of using tags","Use a regular TaskSet if tag-based task filtering is essential to your test"],"exampleFix":"// before\n@task\n@tag(\"smoke\")\n@transition(MyUser.next_step)\ndef browse(self): ...\n// after\n@task\n@transition(MyUser.next_step)\ndef browse(self): ...","handlingStrategy":"validation","validationCode":"for name, m in vars(MyUser).items():\n    assert \"locust_tag_set\" not in dir(m), f\"tags not allowed on {name} in MarkovTaskSet\"","typeGuard":null,"tryCatchPattern":"try:\n    user = MyUser(env)\nexcept MarkovTaskTagError as e:\n    logging.error(e)\n    raise","preventionTips":["Never apply @tag/@tags inside MarkovTaskSet classes","Subset Markov tests by launching separate classes instead of tags","Review imports/copies from regular TaskSets for leftover decorators"],"tags":["locust","markov-taskset","tags","unsupported-feature"],"backgroundTag":"unsupported-decorator-combination","analyzedSha":"f391a716e12c2c712e80b5835e877b7933397453","analyzedAt":"2026-08-29T00:36:13.872Z","schemaVersion":2},"datasetVersion":"2026-08-29T02:17:18.158Z"}