-
Notifications
You must be signed in to change notification settings - Fork 54
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
Give the default failure "reason" when commands failed #2463
Give the default failure "reason" when commands failed #2463
Conversation
8e92687
to
aae31d7
Compare
Codecov Report
Additional details and impacted files
|
reason: String, | ||
}, | ||
} | ||
|
||
fn default_failure_reason() -> String { | ||
"No failure reason is given".to_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.
I'm not happy with this message which raises the question given by who.
That said I agree, it's hard to come with something sensible. "Unknown error"? In any case, as a user, this is frustrating.
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.
User will see this message only when a command is marked with "failed" but no "reason" is specified. If any internal error occurs inside thin-edge product, we always give the specific error message. I'm fine to change the message to anything, but I believe setting the default reason is correct. Otherwise, user might get "missing field reason
at line 6 column 1" error, which is really not okay.
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.
A default is indeed required.
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.
Making the reason
was indirectly solving that problem, right? It forces the users to provide a reason when there's a failure (as long as it is mandatory only for the failed
state). When there's a failure, the user has to create a JSON message with the status
payload anyway. So, why not make him add the reason
field as well? Why give an option to the user to shoot himself in the foot?
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.
So, why not make him add the reason field as well? Why give an option to the user to shoot himself in the foot?
The issue highlighted by @rina23q is that if by mistake no reason is given then the final error message is more then puzzling ( "missing field reason at line 6 column 1"). A default "Unknown reason" string will be clearer both for the agent developer and the end-user.
"No failure reason is given".to_string() | |
"Unknown reason".to_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.
So, why not make him add the reason field as well?
I believe that reason
should not be mandatory. Highly recommended to add the reason for the failure though.
Robot Results
|
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.
Approved.
Without giving the default reason, mappers will parse an error when command status is failed but no "reason" is given. However, "reason" filed should be optional in command payloads. Signed-off-by: Rina Fujino <rina.fujino.23@gmail.com>
aae31d7
to
b53f427
Compare
Proposed changes
Without giving the default reason, mappers will parse an error when command status is failed but no "reason" is given. However, "reason" filed should be optional in command payloads.
This bug was found during writing a unit test for firmware_update support.
The bahaviour is covered by the unit test
handle_log_upload_executing_and_failed_cmd_for_main_device()
.Maybe worth adding a robot test?
Types of changes
Paste Link to the issue
Checklist
cargo fmt
as mentioned in CODING_GUIDELINEScargo clippy
as mentioned in CODING_GUIDELINESFurther comments