# Error displaying fleet agents -"Error fetching agents Cannot read properties of undefined (reading 'map')"

**URL:** <https://discuss.elastic.co/t/error-displaying-fleet-agents-error-fetching-agents-cannot-read-properties-of-undefined-reading-map/339840>\
**Category:** Elasticsearch\
**Tags:** elastic-stack-monitoring, fleet\
**Created:** [August 1, 2023, 5:02pm UTC](https://discuss.elastic.co/t/error-displaying-fleet-agents-error-fetching-agents-cannot-read-properties-of-undefined-reading-map/339840 "2023-08-01T17:02:00Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![M\_S](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/m_s/32/116340_2.png) [@M\_S](https://discuss.elastic.co/u/M_S)\
**Post date:** [August 1, 2023, 5:02pm UTC](https://discuss.elastic.co/t/error-displaying-fleet-agents-error-fetching-agents-cannot-read-properties-of-undefined-reading-map/339840/1 "2023-08-01T17:02:00Z")

</div>

One fine morning, fleet section just decided not to show agents enrolled in a particular policy. I suspected two issues, @timestamp was not present in some of the fleet related indices, I added mapping for the same, second, agents were updating to version 8.9 which caused this. Error is coming from helpers.js file, line number 34. Second issue no clue how to solve. Error is as shown in figure -

 ![fleeterror](https://us1.discourse-cdn.com/elastic/original/3X/0/f/0f2c9a2dfa67557ce171789abd7e8ced8ce3602d.png)

Full Error in kibana log is

```auto
{"service":{"node":{"roles":["background_tasks","ui"]}},"ecs":{"version":"8.6.1"},"@timestamp":"2023-07-27T17:07:04.269+00:00","message":"Cannot read properties of undefined (reading 'map')","error":{"message":"Cannot read properties of undefined (reading 'map')","type":"TypeError","stack_trace":"TypeError: Cannot read properties of undefined (reading 'map')\n at /usr/share/kibana/node_modules/@kbn/fleet-plugin/server/services/agents/helpers.js:34:28\n at Array.map (<anonymous>)\n at searchHitToAgent (/usr/share/kibana/node_modules/@kbn/fleet-plugin/server/services/agents/helpers.js:29:222)\n at Array.map (<anonymous>)\n at Object.getAgentsByKuery (/usr/share/kibana/node_modules/@kbn/fleet-plugin/server/services/agents/crud.js:244:30)\n at runMicrotasks (<anonymous>)\n at processTicksAndRejections (node:internal/process/task_queues:96:5)\n at getAgentsHandler (/usr/share/kibana/node_modules/@kbn/fleet-plugin/server/routes/agent/handlers.js:156:22)\n at Router.handle (/usr/share/kibana/node_modules/@kbn/core-http-router-server-internal/src/router.js:149:30)\n at handler (/usr/share/kibana/node_modules/@kbn/core-http-router-server-internal/src/router.js:115:50)\n at exports.Manager.execute (/usr/share/kibana/node_modules/@hapi/hapi/lib/toolkit.js:60:28)\n at Object.internals.handler (/usr/share/kibana/node_modules/@hapi/hapi/lib/handler.js:46:20)\n at exports.execute (/usr/share/kibana/node_modules/@hapi/hapi/lib/handler.js:31:20)\n at Request._lifecycle (/usr/share/kibana/node_modules/@hapi/hapi/lib/request.js:371:32)\n at Request._execute (/usr/share/kibana/node_modules/@hapi/hapi/lib/request.js:281:9)"},"log":{"level":"ERROR","logger":"plugins.fleet"},"process":{"pid":2786},"trace":{"id":"4de74d693be1afdba"},"transaction":{"id":"cf0bdbe"}}

```

Here is the mentioned lines from 34 to 41 of `/usr/share/kibana/node_modules/@kbn/fleet-plugin/server/services/agents/helpers.js`  
file where the error originates -

```auto
 units: component.units.map(unit => ({ #line 34
      id: unit.id,
      type: unit.type,
      status: unit.status,
      message: unit.message,
      // key-value pairs
      payload: unit.payload
    }))

```

Please help.

---

<div class="post-metadata">

**Author:** ![nchaulet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/nchaulet/32/77896_2.png) [@nchaulet](https://discuss.elastic.co/u/nchaulet)\
**Post date:** [August 1, 2023, 6:15pm UTC](https://discuss.elastic.co/t/error-displaying-fleet-agents-error-fetching-agents-cannot-read-properties-of-undefined-reading-map/339840/2 "2023-08-01T18:15:12Z")

</div>

Hi @M_S

Can I ask you which version of Kibana are you running? this should have been fixed in 8.9, if you are not in 8.9 upgrading should probably fix it.

---

<div class="post-metadata">

**Author:** ![M\_S](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/m_s/32/116340_2.png) [@M\_S](https://discuss.elastic.co/u/M_S)\
**Post date:** [August 2, 2023, 2:38pm UTC](https://discuss.elastic.co/t/error-displaying-fleet-agents-error-fetching-agents-cannot-read-properties-of-undefined-reading-map/339840/3 "2023-08-02T14:38:28Z")

</div>

Precisely this was the issue. Kibana was still in version 8.8 whereas fleet was on latest upgrade.

---

<div class="post-metadata">

**Author:** ![nchaulet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/nchaulet/32/77896_2.png) [@nchaulet](https://discuss.elastic.co/u/nchaulet)\
**Post date:** [August 2, 2023, 8:09pm UTC](https://discuss.elastic.co/t/error-displaying-fleet-agents-error-fetching-agents-cannot-read-properties-of-undefined-reading-map/339840/4 "2023-08-02T20:09:56Z")

</div>

Unfortunately you will have to upgrade Kibana and Elasticsearch to 8.9 to fix that Fleet server version should \<= to Elasticsearch and kibana version. It's documented here [Deploy on-premises and self-managed | Fleet and Elastic Agent Guide [8.9] | Elastic](https://www.elastic.co/guide/en/fleet/8.9/add-fleet-server-on-prem.html#add-fleet-server-on-prem-compatibility)

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [August 30, 2023, 8:10pm UTC](https://discuss.elastic.co/t/error-displaying-fleet-agents-error-fetching-agents-cannot-read-properties-of-undefined-reading-map/339840/5 "2023-08-30T20:10:16Z")

</div>

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