AOSSIE-Org / AOSSIE-Org/EduAid

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

オープン
#467 コメント 4 件 リアクション 0 件 担当者 0 名 GitHub で見る
bug
主要言語
JavaScript
スター
171
フォーク
423
PR マージ指標
30日以内にマージされた PR はありません

説明

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

コントリビューションガイド

このリポジトリのコントリビューションガイドは索引されていません

評価

この issue はまだ評価されていません。

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。