Fix: common: error query for trigger action protocol error
authorJonathan Rajotte <jonathan.rajotte-julien@efficios.com>
Tue, 14 Sep 2021 20:10:36 +0000 (16:10 -0400)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Thu, 23 Sep 2021 15:34:09 +0000 (11:34 -0400)
Observed issue
==============

When listing a trigger with a single non-list action the CLI reports an
error in the protocol resulting in an output with no error accounting
for the action.

 $ lttng list-triggers
  - name: trigger0
    owner uid: 1000
    condition: session rotation ongoing
      session name: test
      errors: none
   action:notify
  Error: Failed to query errors of trigger 'trigger0' (owner uid: 1000): Protocol error occurred

Cause
=====

The `action_path` associated with the query has an index count of 0 as
it should considering that the single root element action element is not
a `list` object.

Inside `lttng_action_path_create_from_payload` a payload view is
initialized with a `len` of 0 since `header->index_count` is 0 as it
should.

The payload view is then validated and is considered invalid since the
validation check for `len` > 0. The error then bubbles up.

Solution
========

Since that the payload view is considered invalid when it is equal to
zero simply handle this special case and call directly
`lttng_action_path_create` with the appropriate parameter.

Known drawbacks
=========

None.

Signed-off-by: Jonathan Rajotte <jonathan.rajotte-julien@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: I8f302c3aa78835342c665793908dc02f0a9dece4

src/common/actions/path.c

index 7f4955475aa9775f9001e9a34aebca0e5b864874..4ee649928f646cee1de22306f71e690fc1bac9fa 100644 (file)
@@ -143,6 +143,13 @@ ssize_t lttng_action_path_create_from_payload(
 
        header = (typeof(header)) header_view.buffer.data;
        consumed_size += header_view.buffer.size;
+
+       /*
+        * An action path of size 0 can exist and represents a trigger with a
+        * single non-list action. Handle it differently since a payload view of
+        * size 0 is considered invalid.
+        */
+       if (header->index_count != 0)
        {
                const struct lttng_payload_view indexes_view =
                                lttng_payload_view_from_view(view,
@@ -161,6 +168,11 @@ ssize_t lttng_action_path_create_from_payload(
                if (!action_path) {
                        goto end;
                }
+       } else {
+               action_path = lttng_action_path_create(NULL, 0);
+               if (!action_path) {
+                       goto end;
+               }
        }
 
        ret = consumed_size;
This page took 0.026921 seconds and 4 git commands to generate.