fix(cv): add Groq timeout, avoid caching fallback resumes for 24h, and clean skillSummary

Open
#4,042 1 comment 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

@SiddheshCodes4554 is already working on this.

Since Dec 3, 2026.

  • #4046 by @SiddheshCodes4554 — open

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
25/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Stale
Tech stack
next.js, supabase, typescript
Domain
ai, backend

Research direction

Read src/lib/cv/cv-ai-generator.ts and src/app/api/cv/generate/route.ts, then inspect test/cv-ai-generator.test.ts. Trace the parallel Groq calls, fallback content, and cache write; add coverage for timeout handling, summary cleanup, empty language lists, and source tracking. Done means fallback resumes are not cached for 24 hours and the listed output and reliability cases are covered. A linked open pull request already addresses this issue.

Written by the indexing model from the issue text.

Description

Summary

The AI resume generator (src/lib/cv/cv-ai-generator.ts and src/app/api/cv/generate/route.ts) has several reliability and output-quality bugs when calling Groq:

  1. No request timeout on parallel Groq calls: callGroqAPI() calls groqChatCompletion() without an AbortSignal.timeout(...). Since generateResumeContent() runs 4 Groq requests in parallel (Promise.all), a single stalled Groq connection hangs the entire /api/cv/generate request instead of aborting and falling back cleanly.
  2. Fallback resumes are cached for 24 hours on transient AI failures: When GROQ_API_KEY is missing or all 4 Groq calls fail/time out, generateResumeContent() returns rule-based fallback content, and /api/cv/generate unconditionally caches it in cv_generated_content for 24 hours (expires_at). A transient Groq outage/rate limit locks users into a template resume for 24 hours unless they manually regenerate (consuming their hourly quota).
  3. Uncleaned / potentially empty skillSummary: generateSkillSummary() returns parsed.summary directly without trimming/cleaning or falling back when parsed.summary.trim() is empty.
  4. Broken sentence in fallbackProfessionalSummary: When contributionScores.topLanguages is empty, fallbackProfessionalSummary() ends with "Proficient in .".

Proposed Fix

  • Add AbortSignal.timeout(15_000) to groqChatCompletion() in callGroqAPI().
  • Track whether AI generation succeeded (source: "ai" | "fallback" on ResumeContent) and skip the 24-hour Supabase cache in /api/cv/generate when source === "fallback".
  • Clean and validate parsed.summary in generateSkillSummary(), falling back to fallbackSkillSummary()'s summary when empty.
  • Omit "Proficient in ." in fallbackProfessionalSummary() when topLanguages is empty.
  • Add unit tests in test/cv-ai-generator.test.ts covering JSON parsing, hallucination-prevention validation, fallback behavior, timeout handling, and source tracking.
Dominant language
TypeScript
Stars
246
Forks
436
Avg merge
9h 33m
Merged PRs (30d)
213

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from Priyanshu-byte-coder/devtrack

All issues in Priyanshu-byte-coder/devtrack

Similar issues

More TypeScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.