Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

BUG: Prevent ai.py import crash when env vars are missing

Open
#263 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
52/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Stale
Tech stack
fastapi, python, supabase
Domain
ai, api, backend

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

  1. Unset SUPABASE_URL/SUPABASE_KEY/GEMINI_API_KEY in the backend environment.
  2. Start the FastAPI app (e.g., uvicorn app.main:app --reload).
  3. 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

  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 AOSSIE-Org/InPactAI

All issues in AOSSIE-Org/InPactAI

Similar issues

More TypeScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.