Input validation for XML launch files

Open
#731 1 comment 1 reaction 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
5/5
Estimated time
Over a week
Newbie friendliness
25/100
Issue type
Feature
Clarity
Needs clarification
Activity status
Stale
Tech stack
python
Domain
tooling

Research direction

No files, tests, or entry points are named. First clarify the validation syntax, supported validation types, error behavior, and scope before locating the XML argument parsing code and defining tests for malformed and valid values.

Written by the indexing model from the issue text.

Description

backlog enhancement

Feature request

Feature description

One of the advantages of using Python-based launch files as opposed to XML is the ability to validate input arguments and parameters. For example, if the launch file allows the user to set the arg robot_ip, it should not accept a malformed address. Instead, it would be nice if it informed the user of the mistake. Other than catching typos, input validation could potentially catch dependency issues, such as missing plugins. I believe validating string types would provide the most benefit, such as IP address, plugin names, file paths, etc. but numerical types could also be validated by checking upper or lower bounds.

In terms of implementation, there are several ways it can be expressed. The simplest solution is to add a regex tag that uses regex, e.g.

<arg name="robot_ip" default="127.0.0.1" regex="^((25[0-5]|(2[0-4]|1\d|[1-9]|)\d)\.?\b){4}$"/>

A more elaborate solution could use dedicated tags for common validation types, e.g.

<arg name="robot_ip" default="127.0.0.1" validators="ip_address"/>
<arg name="web_server" default="http://127.0.0.1:8080" validators="url"/>
<arg name="dof" default="7" validators="one_of([6,7])"/>

I think there are other ways to achieve the same effect. I'm also interested in knowing how others might go about implementing it and what types of validations would provide the most value.

*credit to stackoverflow for IP regex

Dominant language
Python
Stars
156
Forks
200
Avg merge
2d 11h
Merged PRs (30d)
11

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from ros2/launch

All issues in ros2/launch

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.