[BUG] Project Tutor API: unbounded input, missing timeout, and fragile question parsing

Aperta
#4,068 1 commento 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
3/5
Tempo stimato
1-2 giorni
Idoneità per principianti
45/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
github, next.js, typescript
Ambito
api, backend

Direzione di ricerca

Start with src/app/api/project-tutor/route.ts and compare its request handling with the roast route’s readBoundedText(req, 8192); review callGroq and the existing API route tests. Add coverage in test/api-project-tutor-route.test.ts for invalid input, unknown actions, timeouts, and questions responses with surrounding text or an invalid shape. Done when inputs are validated before external calls, Groq has a 15s timeout, and question JSON is extracted and validated.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

bug needs-triage
What happened?

src/app/api/project-tutor/route.ts:

Parses the body with req.json() and passes question into the Groq prompt with no type or length limit; each call is a paid model request. The roast route already uses readBoundedText(req, 8192).
A non-string repoUrl makes repoUrl.match throw, returning 500 instead of 400.
An unknown action still makes three GitHub API calls before returning 400.
callGroq has no AbortSignal timeout (same class as #4035 / #4054).
The questions action only strips code fences before JSON.parse, so any text around the JSON silently falls back to generic questions, and the parsed shape is never validated.

Expected: bound and validate input before any GitHub or model work, use a 15s timeout, extract and validate the JSON.

Found in source review; I’ll add tests in test/api-project-tutor-route.test.ts.

[x] I’d like to work on this.

Steps to reproduce
  1. Sign in and send POST /api/project-tutor with {"repoUrl": 123, "action": "analyze"} → returns 500 instead of 400.
  2. Send {"repoUrl": "https://github.com/vercel/next.js", "action": "bogus"} → three GitHub API calls are made before the 400.
  3. Send action "questions" while Groq returns text around the JSON (e.g. "Here are your questions: {...}") → the user silently gets the hard-coded generic questions.
  4. Send action "chat" with a very large "question" string → it is passed into the Groq prompt unchecked.
  5. If Groq stalls, the request has no timeout (callGroq passes no AbortSignal).
Where is it?

API

Where did you see it?

Local development

Browser and device

N/A (server-side API route)

Screenshots, console errors or logs

No response

Want to fix it?
  • I'd like to work on this. A maintainer will assign you; please don't start before that.
Lingua principale
TypeScript
Stelle
246
Fork
436
Merge medio
9h 33m
PR unite (30g)
213

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di Priyanshu-byte-coder/devtrack

Tutte le issue di Priyanshu-byte-coder/devtrack

Issue simili

Altre issue su TypeScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.