Skip to content

[9.1] [Discover][APM] Check for undefined data from useFetcher in TraceWaterfallEmbeddable (#240843)#241095

Merged
iblancof merged 2 commits intoelastic:9.1from
iblancof:backport/9.1/pr-240843
Oct 29, 2025
Merged

[9.1] [Discover][APM] Check for undefined data from useFetcher in TraceWaterfallEmbeddable (#240843)#241095
iblancof merged 2 commits intoelastic:9.1from
iblancof:backport/9.1/pr-240843

Conversation

@iblancof
Copy link
Contributor

Backport

This will backport the following commits from main to 9.1:

Questions ?

Please refer to the Backport tool documentation

…fall (elastic#240843)

## Summary

Closes elastic#238405

Since we upgraded the error handling strategy to catch Fatal React
Errors, we’ve started seeing `TypeError: Cannot read properties of
undefined (reading 'map')` in versions 8.19.x and 9.1.x.

<img width="809" height="121" alt="Screenshot 2025-10-27 at 16 03 48"
src="https://github.com/user-attachments/assets/042a4118-8294-4701-8d0b-590321a2bde8"
/>

After reviewing the error stack, we found that this occurs because
`traceItems` is occasionally arrive as `undefined`. Although TS enforces
that it should always be defined, a potential API malfunction may cause
this scenario.

To prevent users from encountering an uncontrolled error, this PR adds a
check for `undefined` for `data` coming from the `useFetcher` (more
details in [this
comment](elastic#240843 (comment))).

This ensures that the UI behaves safely even if `traceItems` is
unexpectedly `undefined`.

|Before|After|
|-|-|
|![Screen Recording 2025-10-27 at 15 33
39](https://github.com/user-attachments/assets/6753ed8c-1e37-4117-8ba0-112d996e2066)|<img
width="1405" height="968" alt="Screenshot 2025-10-28 at 14 26 04"
src="https://github.com/user-attachments/assets/1d4453df-25b5-4573-b29f-0da76f42b064"
/>|

I also took the chance to update the UI, so the error message is more
visible:
|Before|After|
|-|-|
|<img width="1405" height="968" alt="Screenshot 2025-10-28 at 14 26 04"
src="https://github.com/user-attachments/assets/1d4453df-25b5-4573-b29f-0da76f42b064"
/>|<img width="1405" height="966" alt="Screenshot 2025-10-28 at 14 24
51"
src="https://github.com/user-attachments/assets/3426defd-58fc-4ea8-950c-1163bb11cb20"
/>|

The same error has been now added to the `TraceWaterfallEmbeddable`:
<img width="1387" height="135" alt="Screenshot 2025-10-28 at 14 27 31"
src="https://github.com/user-attachments/assets/3bd01cb3-b716-4216-82de-ec02d7f01bdf"
/>

(cherry picked from commit 7d2975b)

# Conflicts:
#	x-pack/solutions/observability/plugins/apm/public/embeddable/trace_waterfall/trace_waterfall_embeddable.tsx
@iblancof iblancof added the backport This PR is a backport of another PR label Oct 29, 2025
@iblancof iblancof enabled auto-merge (squash) October 29, 2025 10:11
@botelastic botelastic bot added the Team:obs-ux-infra_services - DEPRECATED DEPRECATED - Use Team:obs-presentation. label Oct 29, 2025
@elasticmachine
Copy link
Contributor

Pinging @elastic/obs-ux-infra_services-team (Team:obs-ux-infra_services)

@iblancof iblancof disabled auto-merge October 29, 2025 10:11
@iblancof iblancof changed the title [9.1] [Discover][APM] Add fallback to traceItems when calling useTraceWaterfall (#240843) [9.1] [Discover][APM] Check for undefined data from useFetcher in TraceWaterfallEmbeddable (#240843) Oct 29, 2025
@iblancof iblancof enabled auto-merge (squash) October 29, 2025 10:17
@elasticmachine
Copy link
Contributor

💔 Build Failed

Failed CI Steps

@iblancof iblancof merged commit 37b1c8a into elastic:9.1 Oct 29, 2025
12 checks passed
@iblancof iblancof deleted the backport/9.1/pr-240843 branch March 13, 2026 10:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport This PR is a backport of another PR Team:obs-ux-infra_services - DEPRECATED DEPRECATED - Use Team:obs-presentation.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants