BUG: Prevent ai.py import crash when env vars are missing
Nobody has claimed this yet.
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 52/100
Research direction
Start with Backend/app/routes/ai.py and reproduce the failure by running uvicorn app.main:app --reload with SUPABASE_URL, SUPABASE_KEY, and GEMINI_API_KEY unset. Trace the import-time validation and AI route handlers; done means the FastAPI app starts, unrelated routes remain available, and AI requests return a clear 500 for missing configuration.
Written by the indexing model from the issue text.
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
- Dominant language
- TypeScript
- Stars
- 102
- Forks
- 144
- PR merge metrics
- No merged PRs in 30d
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from AOSSIE-Org/InPactAI
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
AOSSIE-Org/InPactAI#218 ·
-
Difficulty 1/5 Under an hour Newbie friendliness 68/100
AOSSIE-Org/InPactAI#201 ·
-
Difficulty 5/5 Over a week Newbie friendliness 42/100
AOSSIE-Org/InPactAI#314 ·
-
Difficulty 5/5 Over a week Newbie friendliness 35/100
AOSSIE-Org/InPactAI#312 ·
-
Difficulty 4/5 3-5 days Newbie friendliness 50/100
AOSSIE-Org/InPactAI#307 · 2 comments ·
All issues in AOSSIE-Org/InPactAI
Similar issues
-
blocklist removal
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
MetaMask/eth-phishing-detect#296544 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
pastelsky/bundlephobia#1122 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
-
category/development priority/P2 scope/file-operations scope/testing type/enhancement
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
-
Enatega Customer and Rider app: Add-ons price is not visible to customer after order is placed. Open
Difficulty 2/5 1-3 hours Newbie friendliness 75/100