Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions rcl/src/rcl/arguments.c
Original file line number Diff line number Diff line change
Expand Up @@ -1980,6 +1980,8 @@ _rcl_parse_param_rule(

ret = rcl_lexer_lookahead2_expect(&lex_lookahead, RCL_LEXEME_SEPARATOR, NULL, NULL);
if (RCL_RET_WRONG_LEXEME == ret) {
rcl_reset_error();

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this would (acutally does) delete the error messages provided by underlying implementation.
i think what we should do here is capture the error, reset the buffer, and then set a new formatted message that includes the previous error as context.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Addressed in dd4b6e7. The parser now captures the lexer error before resetting it, then includes that diagnostic as context in the parameter override format message. The regression test checks for both the user-facing guidance and the underlying lexer error.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Follow-up: the initial revision only covered the separator path. The updated change also routes errors reported by _rcl_parse_param_name() through the same context-preserving wrapper.

I verified the updated commit (ff95ccd) in a Rolling container: test_arguments passed, and all 52 CTest entries passed with 0 failures. The test binary was confirmed to load the locally built /tmp/colcon_ws/build/rcl/librcl.so.

RCL_SET_ERROR_MSG("Parameter override rule must have the format 'name:=value'");
ret = RCL_RET_INVALID_PARAM_RULE;
goto cleanup;
}
Expand Down
15 changes: 15 additions & 0 deletions rcl/test/rcl/test_arguments.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,21 @@ TEST_F(TestArgumentsFixture, check_valid_vs_invalid_args) {
EXPECT_FALSE(are_valid_ros_args({"--ros-args", "--log-file-name"}));
}

TEST_F(TestArgumentsFixture, test_parameter_override_missing_assignment_error) {
const char * const argv[] = {"process_name", "--ros-args", "-p", "bla"};
const int argc = sizeof(argv) / sizeof(const char *);
rcl_arguments_t parsed_args = rcl_get_zero_initialized_arguments();

EXPECT_EQ(
RCL_RET_INVALID_ROS_ARGS,
rcl_parse_arguments(argc, argv, rcl_get_default_allocator(), &parsed_args));
const std::string error_message = rcl_get_error_string().str;
EXPECT_NE(
std::string::npos,
error_message.find("Parameter override rule must have the format 'name:=value'"));
rcl_reset_error();
}

TEST_F(TestArgumentsFixture, test_no_args) {
rcl_arguments_t parsed_args = rcl_get_zero_initialized_arguments();
rcl_ret_t ret = rcl_parse_arguments(0, NULL, rcl_get_default_allocator(), &parsed_args);
Expand Down