Hacktoberfest 2026: los issues que los mantenedores marcaron para octubre, abiertos y aptos para principiantes. Explorar issues de Hacktoberfest

Ordinary PDF and AI problems are all reported as "The AI provider failed"

Cerrado
#194 0 comentarios 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 1 día

@Anshuu2004 ya está trabajando en esto.

Desde el 24/10/2026.

  • #197 de @Anshuu2004 — fusionado

Evaluación

Dificultad
4/5
Tiempo estimado
3-5 días
Aptitud para principiantes
55/100
Tipo de issue
Error
Claridad
Bien especificado
Estado de actividad
Activo
Stack tecnológico
python
Área
api, backend, testing

Línea de trabajo

Start with apps/genAI/app/rag/rag_system.py and apps/genAI/app/main.py, then read errors.py and tests/test_generate_quiz.py alongside the existing PDF and unusable-response handling. Check how conftest.py builds PDFs before adding cases for encrypted and corrupt files, wrong-shaped JSON, and non-PDF bytes. Done means each case returns the specified client-facing error and has a test.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

Backend first issue bug help wanted

Several ordinary, user-caused problems in the AI service surface as a 502 blaming the provider, which sends the host to debug the wrong system.

1. A password-protected or corrupt PDF

apps/genAI/app/rag/rag_system.py:68 calls PdfReader(pdf_path).pages with no exception handling:

  • Password-protected PDF → 502 "The AI provider failed: FileNotDecryptedError"
  • Non-PDF bytes sent with a PDF content type → 502 "The AI provider failed: PdfStreamError"

Both are everyday mistakes — a DRM-protected textbook chapter, a truncated upload. The provider was never contacted.

The service already models this correctly elsewhere: PdfHasNoText maps to a 422 in main.py:46. These just need the same treatment.

2. Model output that parses but has the wrong shape

rag_system.py:236 assumes the parsed JSON is a dict containing a list:

payload = _extract_json(str(response.content))
for item in payload.get("questions", []):

_extract_json only guarantees valid JSON, not that shape. Each of these returns 502 "The AI provider failed: AttributeError":

Model returns
[{"text": "q"}] top-level array has no .get
{"questions": "oops"} not iterable as expected
{"questions": {"a": 1}} same

There is already a ValueError → 502 "unusable response" path for output that cannot be parsed at all. These shapes slip past it into the generic handler.

3. The content-type check gives no real guarantee

main.py:77 trusts the client-supplied header:

if file.content_type != "application/pdf":
    raise HTTPException(status_code=400, detail="Only PDF files are allowed.")

Anything labelled application/pdf passes and then fails deep inside pypdf as case 1. A %PDF- magic-byte check on the first bytes written is cheap and definitive.

What a fix looks like
  • Wrap PdfReader and map FileNotDecryptedError to a 422 saying the PDF is password-protected, and a parse failure to a 400 saying the file is not a readable PDF.
  • Validate the parsed payload — isinstance(payload, dict) and questions being a list — and raise ValueError so the existing "unusable response" path handles it.
  • Check the magic bytes rather than only the header.
Tests to add

tests/test_generate_quiz.py is already good on the happy path and on validation. These failure modes are the gap:

  • JSON that parses but has the wrong shape — the existing test_unusable_model_output_is_502 only uses prose, so it exercises a different branch
  • An encrypted PDF and a corrupt one — make_pdf() in conftest.py can only build valid PDFs
  • A provider timeout — errors.py has a 504 branch for APITimeoutError that nothing currently reaches
Definition of done
  • A password-protected PDF returns a 4xx telling the user what is wrong
  • Malformed model output returns the existing "unusable response" message, not an AttributeError
  • A file that is not a PDF is rejected before pypdf sees it
  • Each case has a test
Lenguaje dominante
TypeScript
Estrellas
21
Forks
7
Merge medio
4 h 13 min
PR fusionados (30 d)
20

Preparar el entorno

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de TheCodeHeist-Coder/Rexial

Todos los issues de TheCodeHeist-Coder/Rexial

Issues similares

Más issues de TypeScript

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.