Skip to content

Commit

Permalink
[Stack Monitoring] Add default value for source and target to prevent…
Browse files Browse the repository at this point in the history
… runtime error (elastic#180043)

## 📓 Summary

The issue occurs because when requesting from the server the details
about elasticsearch for the cluster (`POST
/api/monitoring/v1/clusters/{clusterUuid}/elasticsearch`), it includes a
list of shard activities in the response.

Items of this `shardActivity`
([ElasticsearchIndexRecoveryShard](https://github.com/elastic/kibana/blob/main/x-pack/plugins/monitoring/common/types/es.ts#L380))
may have an **optional** `source` property, but once the data reaches
the client app, the current implementation gives for granted this value
will always exist, and when accessing specific properties of `source`,
this generates a runtime error, resulting in a blank screen.

This change uses a default empty `source` and `target` object on the
client to prevent a reference error when accessing their properties and
set them to undefined.

---------

Co-authored-by: Marco Antonio Ghiani <[email protected]>
  • Loading branch information
tonyghiani and Marco Antonio Ghiani authored Apr 5, 2024
1 parent 7a00d2e commit 4c9ab71
Showing 1 changed file with 2 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ export const parseProps = (props) => {
total_time_in_millis: totalTimeInMillis,
start_time: mbStartTime,
total_time: mbTotalTime,
source,
target,
source = {}, // This property is potentially undefined due to a legacy search where `source` is optionally existing
target = {}, // This property is potentially undefined due to a legacy search where `target` is optionally existing
translog,
type,
timezone,
Expand Down

0 comments on commit 4c9ab71

Please sign in to comment.