You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
I found a bug where the action is incorrectly parsed using the generic parser. This happens on commands where action.args is specified before than action.name, as action.name has not been parsed yet and the current logic in unable to determine the action type.
We probably will need to refactor the parsing of commands to receive not only the parser but the request object, which allows better handling of the content and the creation of several copies of the parser.
request.content()
/// Request parsing/// ===============/// Retrieves and generates an array list of commands.XContentParserparser = request.contentParser();
List<Command> commands = newArrayList<>();
ensureExpectedToken(XContentParser.Token.START_OBJECT, parser.nextToken(), parser);
// The array of commands is inside the "commands" JSON object.// This line moves the parser pointer to this object.parser.nextToken();
if (parser.nextToken() == XContentParser.Token.START_ARRAY) {
commands = Command.parseToArray(parser);
} else {
log.error("Token does not match {}", parser.currentToken());
}
Describe the bug
I found a bug where the action is incorrectly parsed using the generic parser. This happens on commands where
action.args
is specified before thanaction.name
, asaction.name
has not been parsed yet and the current logic in unable to determine the action type.To Reproduce
Steps to reproduce the behavior:
🟢 Parsed as
set-group
, asaction.name
is read first.🔴 Parsed as
generic
, asaction.args
is read first.Expected behavior
Commands are parsed using the correct parsed independently of the order of the JSON data.
Plugins
Command Manager.
Additional context
Originally posted by @AlexRuiz7 in #253 (review)
The text was updated successfully, but these errors were encountered: