{"record":{"id":"bcb5fa4dc89e3c25","repo":"locustio/locust","slug":"transition-to-dest-from-task-name-is-inval","errorCode":null,"errorMessage":"Transition to {dest} from {task.__name__} is invalid since no such element exists on class {classname}","messagePattern":"Transition to (.+?) from (.+?) is invalid since no such element exists on class (.+?)","errorType":"validation","errorClass":"InvalidTransitionError","httpStatus":null,"severity":"error","filePath":"locust/user/markov_taskset.py","lineNumber":176,"sourceCode":"def validate_transitions(tasks: list, class_dict: dict, classname: str):\n    \"\"\"\n    Validates that all transitions in Markov tasks point to existing Markov tasks.\n\n    This function checks two conditions for each transition:\n    1. The target task exists in the class\n    2. The target task is also a Markov task (has transitions defined)\n\n    :param tasks: List of Markov tasks to validate\n    :param class_dict: Dictionary containing class attributes and methods\n    :param classname: Name of the class being validated (for error messages)\n    :raises InvalidTransitionError: If a transition points to a non-existent task\n    :raises NonMarkovTaskTransitionError: If a transition points to a task that isn't a Markov task\n    \"\"\"\n    for task in tasks:\n        for dest in task.transitions.keys():\n            dest_task = class_dict.get(dest)\n            if not dest_task:\n                raise InvalidTransitionError(\n                    f\"Transition to {dest} from {task.__name__} is invalid since no such element exists on class {classname}\"\n                )\n            if not is_markov_task(dest_task):\n                raise NonMarkovTaskTransitionError(\n                    f\"{classname}.{dest} cannot be used as a target for a transition since it does not define any transitions of its own.\"\n                    + f\"Used as a transition from {task.__name__}.\"\n                )\n\n\ndef validate_no_unreachable_tasks(tasks: list, class_dict: dict, classname: str):\n    \"\"\"\n    Checks for and warns about unreachable Markov tasks in a MarkovTaskSet.\n\n    This function uses depth-first search (DFS) starting from the first task to identify\n    all reachable tasks. It then warns about any tasks that cannot be reached from the\n    starting task through the defined transitions.\n\n    :param tasks: List of Markov tasks to validate","sourceCodeStart":158,"sourceCodeEnd":194,"githubUrl":"https://github.com/locustio/locust/blob/f391a716e12c2c712e80b5835e877b7933397453/locust/user/markov_taskset.py#L158-L194","documentation":"Every transition target in a MarkovTaskSet must exist as an element on the class. validate_transitions raises InvalidTransitionError when task.transitions references a name that is not found in the class dict — the destination state simply does not exist.","triggerScenarios":"@transition(SomeTask) where SomeTask is spelled wrong, defined in another class, deleted in a refactor, or the target was defined after the decorator referencing it failed to resolve.","commonSituations":"Renaming a task method without updating @transition calls; copying transition definitions between classes; referencing tasks defined on a parent class or imported module not present in the class being validated.","solutions":["Correct the transition target name so it matches a @task method defined on the same MarkovTaskSet class","Define the missing task method on the class","Ensure the target is a method of this class, not an external function or inherited method that the validator cannot see"],"exampleFix":"// before\n@task\n@transition(MyUser.chekout)\ndef browse(self): ...\n// after\n@task\n@transition(MyUser.checkout)\ndef browse(self): ...","handlingStrategy":"validation","validationCode":"for t in MyUser.__dict__.values():\n    for dest in getattr(t, \"transitions\", {}):\n        assert dest in MyUser.__dict__, f\"unknown transition target {dest}\"","typeGuard":null,"tryCatchPattern":"try:\n    validate_markov_chain(tasks, dict(vars(MyUser)), MyUser.__name__)\nexcept InvalidTransitionError as e:\n    logging.error(e)\n    raise","preventionTips":["Rename task methods together with their transition references (IDE rename refactor)","Grep for @transition targets when adding/removing tasks","Run a smoke instantiation of MarkovTaskSet classes in CI"],"tags":["locust","markov-taskset","transition","typo"],"backgroundTag":"invalid-transition-target","analyzedSha":"f391a716e12c2c712e80b5835e877b7933397453","analyzedAt":"2026-08-29T00:36:13.872Z","schemaVersion":2},"datasetVersion":"2026-08-29T02:17:18.158Z"}