Ordinary PDF and AI problems are all reported as "The AI provider failed"
I maintainer di solito rispondono entro 1 giorno
Valutazione
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Idoneità per principianti
- 55/100
Direzione di ricerca
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.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
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
- Lingua principale
- TypeScript
- Stelle
- 21
- Fork
- 7
- Merge medio
- 5h 6m
- PR unite (30g)
- 29
Preparare l'ambiente
- Include un Dockerfile o un file Docker Compose
- Ha un modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di TheCodeHeist-Coder/Rexial
-
bug good first issue help wanted UI & UX
Difficoltà 2/5 1-3 ore Idoneità per principianti 84/100
TheCodeHeist-Coder/Rexial#205 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
The join endpoint returns an error shape the frontend cannot readForse già presa @Anshuu2004 l’ha presa 3 giorni fa. ApertaBackend first issue bug good first issue help wanted
Difficoltà 2/5 1-3 ore Idoneità per principianti 86/100
TheCodeHeist-Coder/Rexial#192 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
bug good first issue help wanted UI & UX
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 95/100
TheCodeHeist-Coder/Rexial#178 · 2 commenti ·
I maintainer di solito rispondono entro 1 giorno
-
bug help wanted UI & UX
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
TheCodeHeist-Coder/Rexial#175 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
bug enhancement good first issue help wanted UI & UX
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
TheCodeHeist-Coder/Rexial#162 ·
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di TheCodeHeist-Coder/Rexial
Issue simili
-
area: server priority: P3 type: bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 83/100
appandflow/stim#4538 ·
I maintainer di solito rispondono entro 1 giorno
-
[BUG] Published Docker images lack the redis extra: HEADROOM_COMPRESS_SESSION_STORE stops startupForse già presa @AlessandroSpallina l’ha presa oggi. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
headroomlabs-ai/headroom#4513 ·
I maintainer di solito rispondono entro 1 giorno
-
bug extension extension: obsidian platform: Windows
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
raycast/extensions#32838 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
copy design-review mac P3
Difficoltà 2/5 1-3 ore Idoneità per principianti 88/100
tosunlab/hisarapp-core#510 ·
-
bug priority-medium to-agent
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
I maintainer di solito rispondono entro 1 giorno