Skip to content

rcl_yaml_param_parser allows two // in node name #301

@sloretz

Description

@sloretz

Bug report

Required Info:

  • Operating System:
    • Ubuntu Bionic
  • Installation type:
    • source
  • Version or commit hash:
    • master
  • DDS implementation:
    • Fast-RTPS
  • Client library (if applicable):
    • N/A

Steps to reproduce issue

Create a yaml file called empty_name_in_ns.yaml in rcl_yaml_param_parser/test with the following

lidar_ns//lidar_w:
  ros__parameters:
    id: 10
    name: front_lidar
    ports: [2438, 2439, 2440]
    driver1:
      dx: 4.56
      dy: 2.30
      fr_sensor_specs: [12, 3, 0, 7]
      bk_sensor_specs: [12.1, -2.3, 5.2, 9.0]
    is_front: true
    driver2:
      dx: 1.23
      dy: 0.45

Add this test block to test_parse_yaml.cpp

TEST(test_file_parser, empty_name_in_ns) {
  rcutils_reset_error();
  EXPECT_TRUE(rcutils_get_cwd(cur_dir, 1024));
  rcutils_allocator_t allocator = rcutils_get_default_allocator();
  char * test_path = rcutils_join_path(cur_dir, "test", allocator);
  char * path = rcutils_join_path(test_path, "empty_name_in_ns.yaml", allocator);
  fprintf(stderr, "cur_path: %s\n", path);
  EXPECT_TRUE(rcutils_exists(path));
  rcl_params_t * params_hdl = rcl_yaml_node_struct_init(allocator);
  EXPECT_FALSE(NULL == params_hdl);
  bool res = rcl_parse_yaml_file(path, params_hdl);
  fprintf(stderr, "%s\n", rcutils_get_error_string_safe());
  EXPECT_FALSE(res);
  rcl_yaml_node_struct_print(params_hdl);
  rcl_yaml_node_struct_fini(params_hdl);
  allocator.deallocate(test_path, allocator.state);
  allocator.deallocate(path, allocator.state);
}

Expected behavior

Parsing should fail to parse the yaml file.

Actual behavior

1:  Node Name                           Parameters
1: lidar_ns//lidar_w
1:                                                 id: 10
1:                                               name: front_lidar
1:                                              ports: 2438, 2439, 2440, 
1:                                         driver1.dx: 4.560000
1:                                         driver1.dy: 2.300000
1:                            driver1.fr_sensor_specs: 12, 3, 0, 7, 
1:                            driver1.bk_sensor_specs: 12.100000, -2.300000, 5.200000, 9.000000, 
1:                                           is_front: true
1:                                         driver2.dx: 1.230000
1:                                         driver2.dy: 0.450000

Additional information

See #299 for another bug about / in the namespace names.

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions