Skip to content

Conversation

@mahmoud-ghalayini
Copy link
Collaborator

Public API Changes

New Exports from rclnodejs:

  • ValidationProblem - Enum for validation issue types
  • MessageValidationError - Error class with structured issue reporting
  • getMessageSchema(typeClass) - Get message schema
  • getFieldNames(typeClass) - Get field names array
  • getFieldType(typeClass, fieldName) - Get field type info
  • validateMessage(obj, typeClass, options) - Validate without throwing
  • assertValidMessage(obj, typeClass, options) - Validate and throw on failure
  • createMessageValidator(typeClass, options) - Create reusable validator

New Options:

  • PublisherOptions.validateMessages - Enable publisher validation
  • ClientOptions.validateRequests - Enable service client validation
  • ActionClientOptions.validateGoals - Enable action client validation

New Methods:

  • Publisher.setValidation(enable) - Toggle validation dynamically
  • Publisher.validationEnabled - Check validation state
  • Client.setValidation(enable) / Client.validationEnabled
  • ActionClient.setValidation(enable) / ActionClient.validationEnabled

Per-call Validation Override:

  • publisher.publish(msg, { validate: true/false })
  • client.sendRequest(req, callback, { validate: true/false })
  • client.sendRequestAsync(req, { validate: true/false })
  • actionClient.sendGoal(goal, feedbackCb, uuid, { validate: true/false })

#1340

@coveralls
Copy link

coveralls commented Dec 3, 2025

Coverage Status

coverage: 80.404% (-2.3%) from 82.751%
when pulling 6368511 on mahmoud-ghalayini:enhance-message-validation-1340
into faaa2d4 on RobotWebTools:develop.

@mahmoud-ghalayini
Copy link
Collaborator Author

No idea why it's only failing in humble pipelines

@minggangw
Copy link
Member

Thanks for submitting the PR, will take a look!

@minggangw
Copy link
Member

No idea why it's only failing in humble pipelines

No worries, sometimes the pipeline fails. I will re-run it.

@minggangw minggangw requested a review from Copilot December 5, 2025 01:53
Copilot finished reviewing on behalf of minggangw December 5, 2025 01:56
Copy link

Copilot AI left a 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 introduces a comprehensive message validation system for rclnodejs, allowing developers to validate ROS 2 messages before publishing or sending them through services and actions. The implementation includes schema introspection capabilities, structured error reporting, and flexible validation options with both opt-in and per-call override mechanisms.

Key Changes:

  • Added message validation API with schema introspection functions (getMessageSchema, getFieldNames, getFieldType)
  • Implemented validation for Publishers, Service Clients, and Action Clients with opt-in configuration
  • Introduced MessageValidationError class with detailed issue reporting
  • Fixed existing bugs in message_translator.js for proper type checking

Reviewed changes

Copilot reviewed 19 out of 26 changed files in this pull request and generated no comments.

Show a summary per file
File Description
types/message_validation.d.ts New TypeScript definitions for validation API including enums, interfaces, and function signatures
types/errors.d.ts Added MessageValidationError and MessageValidationIssue type definitions
types/publisher.d.ts Added PublishOptions interface and validation-related methods/properties for Publisher
types/client.d.ts Added SendRequestOptions interface and validation support for service clients
types/action_client.d.ts Added SendGoalOptions interface and validation support for action clients
types/index.d.ts Added reference to new message validation type definitions
lib/message_validation.js Core validation implementation with schema introspection and message validation logic
lib/errors.js Implemented MessageValidationError class with issue filtering methods
lib/publisher.js Integrated validation into publisher with opt-in and per-publish override support
lib/client.js Integrated validation into service client for request validation
lib/action/client.js Integrated validation into action client for goal validation
index.js Exported new validation functions and error classes to public API
rosidl_gen/message_translator.js Fixed bugs: corrected property access, added wstring support, improved int64/uint64 handling
src/macros.h Code formatting improvements for consistency
test/test-message-validation.js Comprehensive test suite covering all validation features
example/topics/publisher/publisher-validation-example.js Example demonstrating publisher validation features
example/services/client/client-validation-example.js Example demonstrating service client validation
example/actions/action_client/action-client-validation-example.js Example demonstrating action client validation
example/topics/README.md Updated documentation to include validation examples
example/services/README.md Updated documentation with validation example details
example/actions/README.md Updated documentation with action validation examples
example/rate/README.md Minor formatting improvements
example/lifecycle/README.md Minor formatting improvements
example/graph/README.md Minor formatting improvements
CONTRIBUTORS.md Added credit for message validation enhancement

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Member

Choose a reason for hiding this comment

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

the failure on humble pipleline is casued by mis-submitted the prebuilt binary, please remove it and try again, thanks!

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

That's very weird I'm not sure how this file ended up here

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Now a third one is failing 😞

@mahmoud-ghalayini mahmoud-ghalayini force-pushed the enhance-message-validation-1340 branch from eb1a32d to e3710d3 Compare December 5, 2025 08:39
@minggangw minggangw requested a review from Copilot December 5, 2025 10:01
Copilot finished reviewing on behalf of minggangw December 5, 2025 10:04
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 19 out of 25 changed files in this pull request and generated 10 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

## Troubleshooting

### Common Issues

Copy link

Copilot AI Dec 5, 2025

Choose a reason for hiding this comment

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

This change removes a blank line that appears to be unrelated to the message validation feature. This formatting change should not be included in this PR as it modifies content outside the scope of the PR's purpose (message validation).

Suggested change

Copilot uses AI. Check for mistakes.
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Do I need to revert these removed lines? @minggangw

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Ah, by the way I noticed that these changes in the readme happens when I do npm run format

## Troubleshooting

### Common Issues

Copy link

Copilot AI Dec 5, 2025

Choose a reason for hiding this comment

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

This change removes a blank line that appears to be unrelated to the message validation feature. This formatting change should not be included in this PR as it modifies content outside the scope of the PR's purpose (message validation).

Suggested change

Copilot uses AI. Check for mistakes.
- Rate limiting causes message drops
- Expected behavior in the example (only every 200th message processed)
- Use `ros2 topic echo` to see all messages

Copy link

Copilot AI Dec 5, 2025

Choose a reason for hiding this comment

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

This change removes a blank line that appears to be unrelated to the message validation feature. This formatting change should not be included in this PR as it modifies content outside the scope of the PR's purpose (message validation).

Suggested change

Copilot uses AI. Check for mistakes.
## Troubleshooting

### Common Issues

Copy link

Copilot AI Dec 5, 2025

Choose a reason for hiding this comment

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

This change removes a blank line that appears to be unrelated to the message validation feature. This formatting change should not be included in this PR as it modifies content outside the scope of the PR's purpose (message validation).

Suggested change

Copilot uses AI. Check for mistakes.
#### Functionality

This example creates a complete ROS 2 system with multiple nodes and then introspects the graph to display:

Copy link

Copilot AI Dec 5, 2025

Choose a reason for hiding this comment

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

This change removes a blank line that appears to be unrelated to the message validation feature. This formatting change should not be included in this PR as it modifies content outside the scope of the PR's purpose (message validation).

Suggested change

Copilot uses AI. Check for mistakes.
- Ensure action server is running before starting client
- Check that both use the same action name (`fibonacci`)
- Verify action type matches (`test_msgs/action/Fibonacci`)

Copy link

Copilot AI Dec 5, 2025

Choose a reason for hiding this comment

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

This change removes a blank line that appears to be unrelated to the message validation feature. This formatting change should not be included in this PR as it modifies content outside the scope of the PR's purpose (message validation).

Suggested change

Copilot uses AI. Check for mistakes.
- Check server's `goalCallback` return value
- Verify goal message structure is correct
- Ensure server is properly initialized

Copy link

Copilot AI Dec 5, 2025

Choose a reason for hiding this comment

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

This change removes a blank line that appears to be unrelated to the message validation feature. This formatting change should not be included in this PR as it modifies content outside the scope of the PR's purpose (message validation).

Suggested change

Copilot uses AI. Check for mistakes.
- Processing time exceeds rate period
- Solution: Optimize processing or reduce rate frequency
- Monitor actual vs. target frequency

Copy link

Copilot AI Dec 5, 2025

Choose a reason for hiding this comment

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

This change removes a blank line that appears to be unrelated to the message validation feature. This formatting change should not be included in this PR as it modifies content outside the scope of the PR's purpose (message validation).

Suggested change

Copilot uses AI. Check for mistakes.
- Ensure lifecycle publisher is activated in `onActivate()`
- Check that node is in active state
- Verify publisher is created in `onConfigure()`

Copy link

Copilot AI Dec 5, 2025

Choose a reason for hiding this comment

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

This change removes a blank line that appears to be unrelated to the message validation feature. This formatting change should not be included in this PR as it modifies content outside the scope of the PR's purpose (message validation).

Suggested change

Copilot uses AI. Check for mistakes.
- Create timer in `onActivate()`, not `onConfigure()`
- Cancel timer in `onDeactivate()`
- Check timer interval format (BigInt nanoseconds)

Copy link

Copilot AI Dec 5, 2025

Choose a reason for hiding this comment

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

This change removes a blank line that appears to be unrelated to the message validation feature. This formatting change should not be included in this PR as it modifies content outside the scope of the PR's purpose (message validation).

Suggested change

Copilot uses AI. Check for mistakes.
}

function verifyMessage(message, obj) {
function verifyMessage(message, inputObj) {
Copy link
Member

Choose a reason for hiding this comment

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

This function was design to do some basic verification long time ago, will your PR replace its functionality? If yes, I think we can remove it becasue it doesn't get called anymore.

I go through this PR roughly and will try to understand more deeply, thanks!

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yes we can remove it 😃

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.

3 participants