Startup validation: abort early on missing critical configuration
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 180
- Forks
- 137
- Avg merge
- 3d 23h
- Merged PRs (30d)
- 21
Description
Issue
What is the issue?
The application does not validate critical configuration at startup. Missing environment variables are only discovered at runtime when a specific feature is exercised, leading to confusing errors deep in the call stack.
Three cases stand out:
Web server:
GOOGLE_CLIENT_SECRET is assigned directly as app.secret_key with no check. If it is not set, Flask runs with secret_key = None, which silently breaks session signing in production. GOOGLE_CLIENT_ID is similarly absent with no warning, so the OAuth flow fails only when a user attempts to log in.
--generate_embeddings CLI command:
No AI provider key check occurs before the command starts. The missing-key error is only logged inside PromptHandler.__init__, which is called well into the import process, leaving the user with an opaque failure.
--populate_neo4j_db CLI command:
NEO4J_URL defaults silently to localhost:7687. If that instance is not running, the failure surfaces as a connection error inside the Neo4j driver rather than a clear startup message.
Expected Behaviour
The application should check for required configuration as early as possible and exit immediately with a human-readable error message that names the missing variable and explains how to fix it.
Optional services (Neo4j, Redis) that are not configured should produce a visible warning at startup so the operator knows which features will be degraded before any request is served.
Actual Behaviour
- Flask starts with
secret_key = NonewhenGOOGLE_CLIENT_SECRETis not set. --generate_embeddingsfails insidePromptHandlerwith a logged error but no early exit.--populate_neo4j_dbfails with a Neo4j driver connection error rather than a clear config message.- No warnings are produced for missing optional services.
Steps to reproduce
# Start the web server without setting GOOGLE_CLIENT_SECRET
flask run
# Sessions are broken; no startup error is shown
# Run embeddings generation without an AI provider key
python cre.py --generate_embeddings
# Fails inside PromptHandler with a logged error, no early exit
# Run Neo4j population without NEO4J_URL
python cre.py --populate_neo4j_db
# Fails with a Neo4j driver connection error
Contributor guide
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.
Research direction
Start by running the listed reproduction commands, then trace Flask startup, the command branches in cre.py, and PromptHandler.init. Check how GOOGLE_CLIENT_SECRET, GOOGLE_CLIENT_ID, the AI provider key, NEO4J_URL, and optional services are currently handled. Done means missing required configuration exits early with actionable messages, while absent optional services produce startup warnings.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- flask, neo4j, python, redis
- Domain
- authentication, backend, cli, databases
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100