AOSSIE-Org / AOSSIE-Org/EduAid

[BUG]: Backend endpoints return inconsistent error formats (HTML vs JSON)

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

Descripción

### Bug Description

Several backend endpoints return **HTML error pages** instead of JSON for error cases such as invalid input, incorrect HTTP methods, or unexpected failures.

This causes frontend failures when clients attempt to parse responses using `response.json()` and leads to inconsistent and unreliable error handling across the application.

Currently, some routes return JSON errors while others fall back to Flask’s default HTML error responses, breaking the API contract.

### Steps to Reproduce

1. Start the backend server
2. Send a request with missing or invalid input, for example:
- `POST /get_mcq` with an empty JSON body `{}`
3. Or send a request using an incorrect HTTP method:
- `POST /getTranscript` (endpoint only supports GET)
4. Observe the response format

### Logs and Screenshots

Example response observed before the fix:

Image

This causes frontend parsing failures when calling `response.json()`.

### Environment Details

- OS: Windows 10
- Backend: Python (Flask)
- Client used for testing: Thunder Client (VS Code)
- Browser (frontend context): Chrome

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