AOSSIE-Org / AOSSIE-Org/EduAid

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

Aperta
#467 4 commenti 0 reazioni 0 assegnatari Vedi su GitHub
bug
Lingua principale
JavaScript
Stelle
171
Fork
423
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Descrizione

### 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

Guida per i contributori

Nessuna guida per i contributori indicizzata per questo repository

Valutazione

Questa issue non è ancora stata valutata.

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.