fix: guard against null data in chart components during streaming#760
Open
AliMahmoudDev wants to merge 1 commit into
Open
fix: guard against null data in chart components during streaming#760AliMahmoudDev wants to merge 1 commit into
AliMahmoudDev wants to merge 1 commit into
Conversation
Charts component crashes with TypeError during streaming when null data is passed to Recharts. Added null guards in two places: 1. genui-lib/helpers.ts: Added null checks in buildChartData() and buildSliceData() to return empty arrays when labels/series/slices are null during streaming. 2. All chart component files: Added data ?? [] fallback when passing data to Recharts chart components (BarChartCondensed, LineChart, AreaChart, AreaChartCondensed, HorizontalBarChart, PieChart, ScatterChart, RadarChart, RadialChart). Closes thesysdev#355
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fix for #355
Problem
The Charts component crashes with
TypeError: Cannot read properties of null (reading 'map')during streaming rendering. When the OpenUI Renderer passes partial/incomplete data to chart components before the full dataset has streamed in, Recharts'CategoricalChartWrapper.render()crashes because it receives null data.Solution
Added null guards in two places:
genui-lib/helpers.ts: Added null checks at the start ofbuildChartData()andbuildSliceData()to return empty arrays whenlabels,series, orslicesare null during streaming.All chart component files: Added
data ?? []fallback when passing data to Recharts chart components:This ensures that even if null data somehow reaches the chart rendering layer, Recharts will receive an empty array instead of null, preventing the TypeError.
Closes #355