-
Notifications
You must be signed in to change notification settings - Fork 81
Leverage rcl_arguments_get_unparsed_ros() to get unsupported args #1342
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR enhances ROS argument validation by leveraging the RCL API function rcl_arguments_get_unparsed_ros() to detect and report unknown ROS arguments. The implementation replaces the simple boolean check HasUnparsedROSArgs() with a more comprehensive ThrowIfUnparsedROSArgs() function that provides detailed error messages listing the specific unknown arguments.
Key changes:
- Implemented
ThrowIfUnparsedROSArgs()to detect and report unparsed ROS arguments with detailed error messages - Added test coverage for unknown ROS argument detection during both context initialization and node creation
- Integrated the new validation into both
rcl_init()andrcl_node_init()code paths
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| test/test-unparsed-args.js | Adds comprehensive test coverage for unknown ROS argument detection in both context initialization and node creation scenarios |
| src/rcl_utilities.h | Updates function signature from HasUnparsedROSArgs() to ThrowIfUnparsedROSArgs() with additional parameters for error reporting |
| src/rcl_utilities.cpp | Implements the new function with detailed error messages and proper memory management for unparsed argument indices |
| src/rcl_node_bindings.cpp | Integrates the new validation function into node creation with proper error handling |
| src/rcl_context_bindings.cpp | Integrates the new validation function into context initialization (contains a critical memory leak bug) |
Comments suppressed due to low confidence (1)
src/rcl_context_bindings.cpp:85
- Memory leak:
argvis allocated at line 56 but ifThrowIfUnparsedROSArgsthrows an exception at line 76-78, the function returns early before registering theFreeArgscleanup at line 85. TheRCPPUTILS_SCOPE_EXITforFreeArgsshould be moved immediately afterAbstractArgsFromNapiArray(after line 56) to ensure proper cleanup in all error paths, similar to how it's done inrcl_node_bindings.cppat line 191.
ThrowIfUnparsedROSArgs(env, jsArgv, context->global_arguments);
if (env.IsExceptionPending()) {
return env.Undefined();
}
THROW_ERROR_IF_NOT_EQUAL(
RCL_RET_OK, rcl_logging_configure(&context->global_arguments, &allocator),
rcl_get_error_string().str);
RCPPUTILS_SCOPE_EXIT({ FreeArgs(argv, argc); });
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot <[email protected]>
This PR enhances ROS argument validation by leveraging the RCL API function
rcl_arguments_get_unparsed_ros()to detect and report unknown ROS arguments. The implementation replaces the simple boolean checkHasUnparsedROSArgs()with a more comprehensiveThrowIfUnparsedROSArgs()function that provides detailed error messages listing the specific unknown arguments.Key changes:
ThrowIfUnparsedROSArgs()to detect and report unparsed ROS arguments with detailed error messagesrcl_init()andrcl_node_init()code pathsFix: #1330