AOSSIE-Org / AOSSIE-Org/EduAid

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

Ouverte
#467 4 commentaires 0 réactions 0 personnes assignées Voir sur GitHub
bug
Langage dominant
JavaScript
Étoiles
171
Forks
423
Métriques de merge des PR
Aucune PR mergée en 30 j

Description

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

Guide de contribution

Aucun guide de contribution indexé pour ce dépôt

Évaluation

Cette issue n'a pas encore été évaluée.

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.