AOSSIE-Org / AOSSIE-Org/EduAid

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

Abierto
#467 4 comentarios 0 reacciones 0 asignados Ver en GitHub
bug
Lenguaje dominante
JavaScript
Estrellas
171
Forks
423
Métricas de merge de PR
Sin PR fusionados en 30 d

Descripción

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

Guía de contribución

No hay ninguna guía de contribución indexada para este repositorio

Evaluación

Este issue todavía no se ha evaluado.

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.