Importing canvas workpads via saved-objects API results in internal server error

Hi all,

I am running into an issue with importing canvas workpads via the saved-objects API. We have implemented a script that fetches saved objects via "/api/saved_objects". The script fetches kibana dashboards, visualizations, index patterns and canvas workpads. This works fine, there are no problems and we get a list of JSON files representing the fetched saved objects.

For populating an empty kibana instance, these JSON files are then again posted to the saved-objects API. This works perfectly fine for all the saved objects except for the canvas workpads: The POST request for the workpads succeeds and they are then shown in the canvas workpad list. However, when clicking a workpad, kibana displays that an internal server error occurred and does not open the workpad:

In the kibana server log the following error gets spammed:

 error  [14:00:16.933] [warning][stats-collection] TypeError: Cannot read property 'length' of undefined
at length (C:\dev\Software\elastic\kibana-7.3.1-windows-x86_64\x-pack\legacy\plugins\canvas\server\usage/workpad_collector.js:51:92)
at Array.reduce (<anonymous>)
at reduce (C:\dev\Software\elastic\kibana-7.3.1-windows-x86_64\x-pack\legacy\plugins\canvas\server\usage/workpad_collector.js:51:41)
at Array.map (<anonymous>)
at map (C:\dev\Software\elastic\kibana-7.3.1-windows-x86_64\x-pack\legacy\plugins\canvas\server\usage/workpad_collector.js:37:36)
at summarizeWorkpads (C:\dev\Software\elastic\kibana-7.3.1-windows-x86_64\x-pack\legacy\plugins\canvas\server\usage/workpad_collector.js:158:12)
at process._tickCallback (internal/process/next_tick.js:68:7)
log   [14:00:16.956] [warning][stats-collection] Unable to fetch data from canvas collector

The obtained JSON for the workpad is the following:

{
"id":  "workpad-d4fd2982-2301-4aca-b341-e2d683f94f86",
"type":  "canvas-workpad",
"updated_at":  "2019-09-17T13:49:52.305Z",
"version":  "WzI2MCwyXQ==",
"attributes":  {
                   "name":  "test",
                   "width":  1080,
                   "height":  720,
                   "css":  ".canvasPage {\n\n}",
                   "page":  0,
                   "pages":  [
                                 {
                                     "id":  "page-3d6133cd-7077-4775-9042-e532b463107f",
                                     "style":  {
                                                   "background":  "#FFF"
                                               },
                                     "transition":  {

                                                    },
                                     "elements":  [
                                                      {
                                                          "id":  "element-4852d2bf-393f-4874-811e-b5309d8a6d6e",
                                                          "position":  {
                                                                           "left":  20,
                                                                           "top":  20,
                                                                           "width":  700,
                                                                           "height":  300,
                                                                           "angle":  0
                                                                       },
                                                          "expression":  "filters\n| demodata\n| pointseries x=\"project\" y=\"sum(price)\" color=\"state\" size=\"size(username)\"\n| plot defaultStyle={seriesStyle points=5 fill=1}\n| render"
                                                      }
                                                  ],
                                     "groups":  [

                                                ]
                                 }
                             ],
                   "colors":  [
                                  "#37988d",
                                  "#c19628",
                                  "#b83c6f",
                                  "#3f9939",
                                  "#1785b0",
                                  "#ca5f35",
                                  "#45bdb0",
                                  "#f2bc33",
                                  "#e74b8b",
                                  "#4fbf48",
                                  "#1ea6dc",
                                  "#fd7643",
                                  "#72cec3",
                                  "#f5cc5d",
                                  "#ec77a8",
                                  "#7acf74",
                                  "#4cbce4",
                                  "#fd986f",
                                  "#a1ded7",
                                  "#f8dd91",
                                  "#f2a4c5",
                                  "#a6dfa2",
                                  "#86d2ed",
                                  "#fdba9f",
                                  "#000000",
                                  "#444444",
                                  "#777777",
                                  "#BBBBBB",
                                  "#FFFFFF",
                                  "rgba(255,255,255,0)"
                              ],
                   "isWriteable":  true,
                   "assets":  {

                              },
                   "@timestamp":  "2019-09-17T13:49:52.253Z",
                   "@created":  "2019-09-17T13:49:45.304Z"
               },
"references":  [

               ],
"migrationVersion":  {
                         "canvas-workpad":  "7.0.0"
                     }
}

What exactly is breaking here, and what would be the correct way to fetch canvas workpads via the saved-objects API?

Thanks and regards

That looks like a bug:

can you please log it here? https://github.com/elastic/kibana/issues

Thanks,
Bhavya

Hi @bhavyarm

Thank you for the quick reply, I have created this issue over on github.

Kind regards

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.