Skip to content

Commit

Permalink
Reject wrong lifecycle transitions without crash (ros2#1209)
Browse files Browse the repository at this point in the history
Signed-off-by: Christian Bitter <[email protected]>
  • Loading branch information
chrisbitter committed Jul 22, 2024
1 parent 43198cb commit 312314e
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions rclpy/rclpy/lifecycle/node.py
Original file line number Diff line number Diff line change
Expand Up @@ -350,6 +350,12 @@ def __on_change_state(
):
self.__check_is_initialized()
transition_id = req.transition.id

available_transition_ids = [t[0] for t in self._state_machine.available_transitions]
if transition_id not in available_transition_ids:
resp.success = False
return resp

if req.transition.label:
try:
transition_id = self._state_machine.get_transition_by_label(req.transition.label)
Expand Down

0 comments on commit 312314e

Please sign in to comment.