AOSSIE-Org / AOSSIE-Org/EduAid

[BUG]: React app crashes with unhandled TypeError (forEach) when backend returns empty data for complex Unicode input

Offen
#467 4 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen
bug
Vorherrschende Sprache
JavaScript
Sterne
171
Forks
423
PR-Merge-Kennzahlen
Keine gemergten PRs in 30 T.

Beschreibung

### Bug Description

When generating questions using highly complex Unicode/Zalgo text, the backend successfully returns a 200 response, but the generated data structure is empty/malformed. The React frontend attempts to iterate over this undefined data using .forEach() inside a useEffect hook, causing a fatal React runtime crash.

**Expected Behavior:**

The frontend should defensively check the API response before iterating. If the data is undefined or not an array, it should safely fall back, stop the loading state, and display a user friendly error message (e.g "Could not generate questions from this text").

**Proposed Fix:**

I will trace the .forEach call in the frontend component (likely in the Output rendering or state initialization) and add optional chaining (?.forEach) or an Array.isArray() type guard, preventing the app from crashing. I will open a PR for this immediately.

### Steps to Reproduce

1. Start the local backend and frontend servers.
2. Go to the text input generator.
3. Paste a massive block of Zalgo/corrupted Unicode text.
4. Click Generate.
5. Observe the React unhandled runtime error overlay: TypeError: Cannot read properties of undefined (reading 'forEach').

### Logs and Screenshots

Image

Image

Image

### Environment Details

_No response_

### Impact

High - Major feature is broken

### Code of Conduct

- [x] I have joined the [Discord server](https://discord.gg/hjUhu33uAn) and will post updates there
- [x] I have searched existing issues to avoid duplicates

Beitragsleitfaden

Für dieses Repository ist kein Beitragsleitfaden indexiert

Bewertung

Dieses Issue wurde noch nicht bewertet.

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.