-
Notifications
You must be signed in to change notification settings - Fork 139
Open
Description
Is there an existing issue for this?
- I have searched the existing issues
What happened?
📌 Issue Overview
Importing Backend/app/routes/ai.py currently raises ValueError at module import if SUPABASE_URL, SUPABASE_KEY, or GEMINI_API_KEY are unset. This aborts FastAPI startup, so the entire API is down when any of those env vars are missing—blocking unrelated routes.
🔍 Steps to Reproduce
- Unset SUPABASE_URL/SUPABASE_KEY/GEMINI_API_KEY in the backend environment.
- Start the FastAPI app (e.g.,
uvicorn app.main:app --reload). - Observe startup failure.
🎯 Expected Behavior
The app should start; only the AI endpoints should fail gracefully per-request, returning a clear 500 explaining missing config.
🚨 Actual Behavior
FastAPI fails at import time with ValueError("Missing required environment variables: SUPABASE_URL, SUPABASE_KEY, GEMINI_API_KEY"), preventing any route from serving.
📷 Screenshot
N/A (startup crash)
💡 Suggested Improvements
- Move env validation from module import to within the AI route handlers.
- On missing keys, return 500 JSON with a clear message; log a startup warning instead of raising.
- Add a lightweight check/test to cover the missing-env path.
Record
- I agree to follow this project's Code of Conduct
- I want to work on this issue
Metadata
Metadata
Assignees
Labels
No labels