Skip to content

Conversation

@ElshadHu
Copy link
Contributor

Public API Changes

Description

I fixed a bug in Action.sendGoal where the method was checking the result field instead of the status field to determine action success/failure. This caused STATUS_CANCELED and other status codes to be handled incorrectly.

After reading the documentation, I realized that action result messages contain two fields:

  • result : A simplified success/failure indicator
  • status : The authoritative status

I updated the sendGoal method in src/core/Action.ts to check message.status against GoalStatus.STATUS_SUCCEEDED as the primary indicator of success. For all other status values, I route to the failure callback with descriptive error messages based on the specific status code.

// Check status code instead of result field
const status = message.status as GoalStatus;

if (status === GoalStatus.STATUS_SUCCEEDED) {
  resultCallback(message.values as TResult);
} else {
  // Handle failures with appropriate error messages
  failedCallback(errorMessage);
}

Testing

I added comprehensive unit tests in test/actionSendgoal.test.ts covering:

  • GoalStatus values (SUCCEEDED, CANCELED, ABORTED, CANCELING, UNKNOWN)
  • Feedback message handling
  • Edge case where result and status fields contradict each other

References

If there is any issue, please let me know.

Fixes #889

@EzraBrooks EzraBrooks requested a review from sea-bass November 18, 2025 22:39
@EzraBrooks
Copy link
Collaborator

@sea-bass since you're more familiar with the protocol than I am, can you give this a functional review pass before I give it a typescript review pass?

Copy link
Contributor

@sea-bass sea-bass left a comment

Choose a reason for hiding this comment

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

Added functionality looks good, but I think we probably still want to leave in a case to catch where message.result is false, implying something may have gone wrong in the backend implementation?

@ElshadHu
Copy link
Contributor Author

Added functionality looks good, but I think we probably still want to leave in a case to catch where message.result is false, implying something may have gone wrong in the backend implementation?

Thanks for the feedback, in that case do you want me to handle message.result ? I mean, basically combining the way it is in the codebase and my functionality ?

Copy link
Contributor

@sea-bass sea-bass left a comment

Choose a reason for hiding this comment

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

LGTM -- over to you, @EzraBrooks

Copy link
Collaborator

@EzraBrooks EzraBrooks left a comment

Choose a reason for hiding this comment

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

LGTM with one future proofing nit

Comment on lines 80 to 83
const baseError =
typeof message.values === "string" ? message.values : "";

let errorMessage: string;
Copy link
Collaborator

Choose a reason for hiding this comment

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

What if we made a class GoalError extends Error that did this template interpolation in its constructor and then we called String() on the error before sending it to the failedCallback? That way in the future if the error handling here changes to include a throw, we already have an error type for it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Is it okay to put GoalError on top of Action.ts ? To be honest i did not find any file that contains custom error classes.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Yep, that's fine!

@EzraBrooks
Copy link
Collaborator

@ElshadHu do you mind if I push a commit to get it a bit closer to what I intended to guide you to, so we don't have to go back and forth?

@ElshadHu
Copy link
Contributor Author

@ElshadHu do you mind if I push a commit to get it a bit closer to what I intended to guide you to, so we don't have to go back and forth?

Sure

@EzraBrooks
Copy link
Collaborator

Thanks! if my change looks good to you (and I didn't break the tests 😆) I'm happy to merge this now.

@ElshadHu
Copy link
Contributor Author

Thanks! if my change looks good to you (and I didn't break the tests 😆) I'm happy to merge this now.

Thanks for the help, It seems perfect now.

@EzraBrooks
Copy link
Collaborator

jazzy and kilted are broken (#1104) so we're just looking for humble here.

Copy link
Collaborator

@EzraBrooks EzraBrooks left a comment

Choose a reason for hiding this comment

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

Thanks for the contribution!

@EzraBrooks EzraBrooks merged commit 5614ed4 into RobotWebTools:develop Nov 19, 2025
8 of 14 checks passed
@ElshadHu
Copy link
Contributor Author

Thanks for the contribution!

It is my pleasure to contribute to such a nice repo.

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.

Ros2 Action client does not properly handle status of action response.

3 participants