Skip to content

fix: parse respawn_max_retries YAML strings#969

Open
Lidang-Jiang wants to merge 1 commit intoros2:rollingfrom
Lidang-Jiang:fix/respawn-max-retries-yaml-string
Open

fix: parse respawn_max_retries YAML strings#969
Lidang-Jiang wants to merge 1 commit intoros2:rollingfrom
Lidang-Jiang:fix/respawn-max-retries-yaml-string

Conversation

@Lidang-Jiang
Copy link
Copy Markdown

Summary

Parse YAML string values for respawn_max_retries into integers during frontend parsing, and reject empty strings and booleans with a clear ValueError.

Closes #968

Before
$ python direct_parse_respawn_max_retries.py  # upstream/rolling
"'0'" -> '0' (str)
"''" -> '' (str)
'true' -> True (bool)
After
$ git diff --check

$ python3 -m py_compile launch/launch/actions/execute_process.py launch_yaml/test/launch_yaml/test_executable.py
$WORKSPACE/python310_torch25_cuda/lib/python3.10/site-packages/xpytorch_import_hook.py:6: UserWarning: pkg_resources is deprecated as an API. See https://setuptools.pypa.io/en/latest/pkg_resources.html. The pkg_resources package is slated for removal as early as 2025-11-30. Refrain from using this package or pin to Setuptools<81.
  import pkg_resources

$ ruff check launch/launch/actions/execute_process.py launch_yaml/test/launch_yaml/test_executable.py
All checks passed!

$ python direct_parse_respawn_max_retries.py  # patched worktree
"'0'" -> 0 (int)
"''" -> ValueError: Attribute respawn_max_retries of Entity `executable` expected to be an integer but got ``
'true' -> ValueError: Attribute respawn_max_retries of Entity `executable` expected to be an integer but got `True`

$ python -m pytest -q launch_yaml/test/launch_yaml/test_executable.py::test_executable_respawn_max_retries_string_zero launch_yaml/test/launch_yaml/test_executable.py::test_executable_respawn_max_retries_empty_string_error launch_yaml/test/launch_yaml/test_executable.py::test_executable_respawn_max_retries_bool_error
...                                                                      [100%]
=============================== warnings summary ===============================
test/launch_yaml/test_executable.py::test_executable_respawn_max_retries_string_zero
  $WORKSPACE/ros2-contrib/worktrees/launch-968/launch/launch/frontend/parser.py:96: DeprecationWarning: SelectableGroups dict interface is deprecated. Use select.
    groups = entry_points.get('launch.frontend.parser', [])

-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html
3 passed, 1 warning in 0.11s

Test plan

  • git diff --check
  • python3 -m py_compile launch/launch/actions/execute_process.py launch_yaml/test/launch_yaml/test_executable.py
  • ruff check launch/launch/actions/execute_process.py launch_yaml/test/launch_yaml/test_executable.py
  • Direct parser check for '0', '', and true
  • python -m pytest -q launch_yaml/test/launch_yaml/test_executable.py::test_executable_respawn_max_retries_string_zero launch_yaml/test/launch_yaml/test_executable.py::test_executable_respawn_max_retries_empty_string_error launch_yaml/test/launch_yaml/test_executable.py::test_executable_respawn_max_retries_bool_error

Signed-off-by: Lidang Jiang <lidangjiang@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[launch_yaml] Inconsistent handling of respawn_max_retries leads to runtime TypeError and broken shutdown

1 participant