Skip to content

## Bug / Robustness: No visible error handling for Gemini API failures (rate limits, invalid key, malformed extraction) #1206

Description

@prince-pokharna

Description

StudyPlan's entire core value proposition is: "Paste messy text → AI extracts tasks → Structured Tasks." This depends entirely on a single external call to the Google Gemini API per the documented architecture (AI Layer (Gemini API)). Based on the README and file structure, there's no dedicated error-handling module or documented behavior for:

  • Missing/invalid GEMINI_API_KEY (the .env.example only documents the key itself, not what happens if it's wrong)
  • Gemini API rate limiting or downtime
  • The AI returning malformed/non-JSON output that can't be parsed into "Dates, Subjects" as the architecture diagram describes

Why This Matters

Since there is "Zero Manual Entry" by design, an AI extraction failure with no graceful fallback means the user is left with a blank screen and no path forward — a hard usability dead-end for the app's single primary use case.

Proposed Scope

  • Add explicit try/catch around the Gemini API call in server.js
  • Return structured error responses (e.g. { error: "extraction_failed", message: "..." }) instead of letting the request hang or 500
  • On the frontend (app.js), show a clear message: "Couldn't extract tasks from that text — try rephrasing or check back in a moment", with an option to manually add the task instead
  • Add a startup check that warns in the console (not just a silent failure) if GEMINI_API_KEY is missing from .env

Acceptance Criteria

  • API key missing → clear console warning at server startup, not a runtime crash
  • Gemini failures return a structured JSON error
  • Frontend shows an actionable error message and a manual-entry fallback path

Labels: bug, enhancement, backend, priority: high

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions