Describe the Bug
_call_groq (backend/app/services/insights_service.py:14) does data = response.json() then returns data["choices"][0]["message"]["content"] with no status check. GROQ_API_KEY defaults to "" (configuration.py:19), so with no key configured Groq returns a 401 body (no choices) → KeyError → /insights/weekly 500s. Same happens on a Groq rate-limit or model error.
Where
Steps to Reproduce
- Leave
GROQ_API_KEY unset (its default)
- Call
/insights/weekly
- Endpoint 500s
Expected Behavior
Degrade gracefully — check the status / confirm choices exists and return {"message": "AI insight unavailable"} (or a clean HTTPException); short-circuit with a friendly message when the key isn't set.
Screenshots / Terminal Output
KeyError: 'choices' from insights_service.py when Groq returns a non-200 body.
Environment
- OS: any
- Browser (if frontend): n/a — backend
- CLI version (if CLI): n/a
- Commit:
f3dd729
Additional Context
The frontend does swallow this (DashboardPage.tsx:55), but the backend still logs 500s and returns nothing useful. Happy to take it if you assign me.
Contributing as part of Elite Coders Summer of Code (ECSoC 2026).
Describe the Bug
_call_groq(backend/app/services/insights_service.py:14) doesdata = response.json()then returnsdata["choices"][0]["message"]["content"]with no status check.GROQ_API_KEYdefaults to""(configuration.py:19), so with no key configured Groq returns a 401 body (nochoices) →KeyError→/insights/weekly500s. Same happens on a Groq rate-limit or model error.Where
clutch-cli)Steps to Reproduce
GROQ_API_KEYunset (its default)/insights/weeklyExpected Behavior
Degrade gracefully — check the status / confirm
choicesexists and return{"message": "AI insight unavailable"}(or a cleanHTTPException); short-circuit with a friendly message when the key isn't set.Screenshots / Terminal Output
KeyError: 'choices'frominsights_service.pywhen Groq returns a non-200 body.Environment
f3dd729Additional Context
The frontend does swallow this (
DashboardPage.tsx:55), but the backend still logs 500s and returns nothing useful. Happy to take it if you assign me.Contributing as part of Elite Coders Summer of Code (ECSoC 2026).