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 = None when GOOGLE_CLIENT_SECRET is not set.
--generate_embeddings fails inside PromptHandler with a logged error but no early exit.
--populate_neo4j_db fails 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
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_SECRETis assigned directly asapp.secret_keywith no check. If it is not set, Flask runs withsecret_key = None, which silently breaks session signing in production.GOOGLE_CLIENT_IDis similarly absent with no warning, so the OAuth flow fails only when a user attempts to log in.--generate_embeddingsCLI 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_dbCLI command:NEO4J_URLdefaults silently tolocalhost: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
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.Steps to reproduce