Skip to content

fix: guard against null data in chart components during streaming#760

Open
AliMahmoudDev wants to merge 1 commit into
thesysdev:mainfrom
AliMahmoudDev:fix/charts-null-data-guard
Open

fix: guard against null data in chart components during streaming#760
AliMahmoudDev wants to merge 1 commit into
thesysdev:mainfrom
AliMahmoudDev:fix/charts-null-data-guard

Conversation

@AliMahmoudDev

Copy link
Copy Markdown

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:

  1. genui-lib/helpers.ts: Added null checks at the start of buildChartData() and buildSliceData() to return empty arrays when labels, series, or slices are null during streaming.

  2. All chart component files: Added data ?? [] fallback when passing data to Recharts chart components:

    • BarChartCondensed.tsx
    • LineChart.tsx
    • AreaChart.tsx
    • AreaChartCondensed.tsx
    • HorizontalBarChart.tsx
    • PieChart.tsx
    • ScatterChart.tsx
    • RadarChart.tsx
    • RadialChart.tsx

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

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Charts component crashes with TypeError during streaming: null data passed to Recharts

1 participant