Ordinary PDF and AI problems are all reported as "The AI provider failed"
Los mantenedores suelen responder en 1 día
Evaluación
- Dificultad
- 4/5
- Tiempo estimado
- 3-5 días
- Aptitud para principiantes
- 55/100
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
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
PdfReaderand mapFileNotDecryptedErrorto 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)andquestionsbeing a list — and raiseValueErrorso 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_502only uses prose, so it exercises a different branch - An encrypted PDF and a corrupt one —
make_pdf()inconftest.pycan only build valid PDFs - A provider timeout —
errors.pyhas a504branch forAPITimeoutErrorthat 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
- 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 TheCodeHeist-Coder/Rexial
-
documentation good first issue help wanted
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
TheCodeHeist-Coder/Rexial#195 · 2 comentarios ·
Los mantenedores suelen responder en 1 día
-
One PDF upload freezes the whole AI service, including its health checkPosiblemente ocupada @Anshuu2004 la tomó hoy. AbiertoBackend first issue bug help wanted
Dificultad 2/5 1-3 horas Aptitud para principiantes 84/100
TheCodeHeist-Coder/Rexial#193 · 2 comentarios ·
Los mantenedores suelen responder en 1 día
-
The join endpoint returns an error shape the frontend cannot readPosiblemente ocupada @Anshuu2004 la tomó hoy. AbiertoBackend first issue bug good first issue help wanted
Dificultad 2/5 1-3 horas Aptitud para principiantes 86/100
TheCodeHeist-Coder/Rexial#192 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
Registering without a password returns a 500 instead of telling you what is missingPosiblemente ocupada @Anshuu2004 la tomó hoy. AbiertoBackend first issue bug good first issue help wanted
Dificultad 2/5 1-3 horas Aptitud para principiantes 82/100
TheCodeHeist-Coder/Rexial#191 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
CI does not run the frontend testsPosiblemente ocupada @nayan45633 la tomó hoy. AbiertoBackend first issue good first issue help wanted
Dificultad 2/5 1-3 horas Aptitud para principiantes 76/100
TheCodeHeist-Coder/Rexial#188 · 2 comentarios ·
Los mantenedores suelen responder en 1 día
Todos los issues de TheCodeHeist-Coder/Rexial
Issues similares
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 68/100
awesome-dsh-plugin/awesome-dsh-plugin#9184 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 75/100
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 85/100
farion1231/cc-switch#8829 ·
Los mantenedores suelen responder en 1 día
-
[core-client] Remove unused hand-maintained transport helpers after the definition-table cutoverAbiertodoc-audit enhancement
Dificultad 2/5 1-3 horas Aptitud para principiantes 88/100
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 85/100