/api/user-papers and /api/upload return 500 for malformed requests
Los mantenedores suelen responder en 4 días
Evaluación
- Dificultad
- 2/5
- Tiempo estimado
- 1-3 horas
- Aptitud para principiantes
- 35/100
- Tipo de issue
- Error
- Claridad
- Bien especificado
- Estado de actividad
- Estancado
- Stack tecnológico
- mongodb, next.js, typescript
Línea de trabajo
Start with the route handlers at src/app/api/user-papers/route.ts and src/app/api/upload/route.ts, then check how their inputs reach Mongoose and arrayBuffer(). Add request validation that returns 400 for malformed input, including the subject limit and the single-file rule when isPdf is true. Done when the reproduction requests return 400 with clear messages and valid requests still work.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
Describe the bug
These routes dont check the shape of their input so bad requests become 500 instead of 400
/api/user-paperscasts the body straight toStoredSubjectsand passes it to$in, abody that isnt an array of strings (e.g.{}or"x") makes Mongoose throw, which becomes a 500, theres also no cap on how many subjects can be sent
https://github.com/CodeChefVIT/papers-codechef/blob/6e3aa1152a34c7eb46d36f58294dffd9ff3b3c7b/src/app/api/user-papers/route.ts#L9/api/uploadcasts everyfilesentry toFile. A text value infilesfails atarrayBuffer()which becomes a 500, w/isPdf=true, every file after the first is silently ignored instead of rejected
https://github.com/CodeChefVIT/papers-codechef/blob/6e3aa1152a34c7eb46d36f58294dffd9ff3b3c7b/src/app/api/upload/route.ts#L11
To Reproduce
POST /api/user-paperswith body{}-> 500 "Failed to fetch papers."POST /api/uploadwith form fieldfiles=hello(text, not a file) -> 500 "Failed to upload papers".
Expected behavior
400 with a clear message. zod is already a dependency, so a small schema per route would work, an array of strings with a max length for user papers, and File instances (exactly one when isPdf) for upload
- Lenguaje dominante
- TypeScript
- Estrellas
- 23
- Forks
- 67
- Merge medio
- 2 d 17 h
- PR fusionados (30 d)
- 7
Preparar el entorno
- Incluye un Dockerfile o un archivo de Docker Compose
- Tiene una plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de CodeChefVIT/papers-codechef
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 68/100
CodeChefVIT/papers-codechef#577 ·
Los mantenedores suelen responder en 4 días
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
CodeChefVIT/papers-codechef#552 · 1 comentario · 1 reacción ·
Los mantenedores suelen responder en 4 días
-
/api/upcoming-papers Throws 404 When No Exams are ActivePosiblemente ocupada @Dx-Alz-xD la tomó hace 16 días. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 68/100
CodeChefVIT/papers-codechef#549 · 1 reacción ·
Los mantenedores suelen responder en 4 días
-
Dificultad 3/5 1-2 días Aptitud para principiantes 69/100
CodeChefVIT/papers-codechef#576 ·
Los mantenedores suelen responder en 4 días
-
Dificultad 3/5 1-2 días Aptitud para principiantes 64/100
CodeChefVIT/papers-codechef#575 ·
Los mantenedores suelen responder en 4 días
Todos los issues de CodeChefVIT/papers-codechef
Issues similares
-
good first issue help wanted
Dificultad 2/5 Menos de una hora Aptitud para principiantes 86/100
Intelligenza-Umana/intelligenza-umana-web#16 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
Los mantenedores suelen responder en 1 día
-
bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 82/100
open-webui/open-webui#35184 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 76/100
danielmiessler/LifeOS#3001 ·
Los mantenedores suelen responder en 5 días
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 84/100
Los mantenedores suelen responder en 1 día