Skip to content

Startup validation: abort early on missing critical configuration #851

@shiwani42

Description

@shiwani42

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions