-
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
Fix a method to split SmartREST messages and improve failure reason #1692
Fix a method to split SmartREST messages and improve failure reason #1692
Conversation
Case 1: Quotes are ignored on multiline commands if the line ends with a quoteThere seems to be an issue when handling the newline split logic and double quotes. I have a suspicion it is swallowing the last character (or the last character is just being forgotten) For example if you take a multiline command, if a line ends in a double quote ( Works (with a dummy trailing space at the end of the first line, after the closing double quote) echo "testme"
echo "test again" Does not work (no trailing space on the first line) echo "testme"
echo "test again" Case 2: Commas cause the command to be truncatedIf a comma occurs on another line, then only the lines up until the line with the comma is sent to the plugin. For example the following command (which should produce 3 lines on the stdout, only returns the first 2) echo "line 1";
echo "line 2";
echo "line, 3"; Output
Where as the expected output is:
|
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
When receiving multiline SmartREST messages, splitting simply by `\n` is not a right approach because a SmartREST message can also contain `\n`, e.g. an argument of c8y_Command. Also, in case of an operation failure, giving only the last line of stderr is not easy enough for users to understand why the operation failed. It should give also the whole context as much as possible. Resolves thin-edge#1687 Signed-off-by: Rina Fujino <18257209+rina23q@users.noreply.github.com>
39f2dd8
to
0e6d88d
Compare
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
We found the root cause and it was the shell handler script which was causing the errors. The example in the ticket has also been updated, #1687 |
Proposed changes
When receiving multiline SmartREST messages, splitting simply by
\n
is not a right approach because a SmartREST message can also contain\n
, e.g. an argument of c8y_Command.Also, in case of an operation failure, giving only the last line of stderr is not easy enough for users to understand why the operation failed. It should give also the whole context as much as possible.
Types of changes
Paste Link to the issue
#1687
Checklist
cargo fmt
as mentioned in CODING_GUIDELINEScargo clippy
as mentioned in CODING_GUIDELINESFurther comments