-
Notifications
You must be signed in to change notification settings - Fork 414
Fix: Check status code in Action.sendGoal instead of result field #1103
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
Fix: Check status code in Action.sendGoal instead of result field #1103
Conversation
|
@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? |
sea-bass
left a comment
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.
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 |
sea-bass
left a comment
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.
LGTM -- over to you, @EzraBrooks
EzraBrooks
left a comment
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.
LGTM with one future proofing nit
src/core/Action.ts
Outdated
| const baseError = | ||
| typeof message.values === "string" ? message.values : ""; | ||
|
|
||
| let errorMessage: string; |
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.
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.
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.
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.
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.
Yep, that's fine!
|
@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? |
This reverts commit a4f9725.
Sure |
|
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. |
|
jazzy and kilted are broken (#1104) so we're just looking for humble here. |
EzraBrooks
left a comment
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.
Thanks for the contribution!
It is my pleasure to contribute to such a nice repo. |
Public API Changes
Description
I fixed a bug in
Action.sendGoalwhere the method was checking theresultfield instead of thestatusfield to determine action success/failure. This causedSTATUS_CANCELEDand 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 indicatorstatus: The authoritative statusI updated the
sendGoalmethod insrc/core/Action.tsto checkmessage.statusagainstGoalStatus.STATUS_SUCCEEDEDas 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.Testing
I added comprehensive unit tests in
test/actionSendgoal.test.tscovering:resultandstatusfields contradict each otherReferences
If there is any issue, please let me know.
Fixes #889