Skip to content

feat: validate critical config at startup and abort with clear messages#852

Open
shiwani42 wants to merge 1 commit intoOWASP:mainfrom
shiwani42:feat/startup-config-validation
Open

feat: validate critical config at startup and abort with clear messages#852
shiwani42 wants to merge 1 commit intoOWASP:mainfrom
shiwani42:feat/startup-config-validation

Conversation

@shiwani42
Copy link
Copy Markdown

Fixes #851

What changed

Added application/validate_config.py with three focused validators:

validate_web_config(mode)
Called from create_app() when running in web server mode. Checks that GOOGLE_CLIENT_SECRET and GOOGLE_CLIENT_ID are set and exits with a clear error if either is missing and NO_LOGIN is not set. Logs warnings when NEO4J_URL or REDIS_URL are absent. Skipped entirely in test/testing mode and when a custom conf object is provided (CLI db_connect path).

validate_embeddings_config()
Called in cre_main.run() immediately before --generate_embeddings. Exits if none of OPENAI_API_KEY, GEMINI_API_KEY, or GCP_NATIVE is configured.

validate_neo4j_config()
Called in cre_main.run() immediately before --populate_neo4j_db. Exits if NEO4J_URL is not set.

Tests

13 new tests in application/tests/validate_config_test.py covering:

  • test mode is skipped entirely
  • exits when Google credentials are missing
  • skips auth check when NO_LOGIN is set
  • passes when all required credentials are present
  • warns but does not exit for missing optional services
  • exits for missing AI provider before embeddings generation
  • exits for missing NEO4J_URL before Neo4j population

Add application/validate_config.py with three focused validators:

- validate_web_config(mode): checks GOOGLE_CLIENT_SECRET and
  GOOGLE_CLIENT_ID at web server startup. Exits with a clear error
  if either is missing and NO_LOGIN is not set. Logs warnings when
  NEO4J_URL or REDIS_URL are absent so optional-service failures are
  visible immediately rather than surfacing deep in a request. Skipped
  in test/testing mode.

- validate_embeddings_config(): called in cre_main.run() before
  --generate_embeddings. Exits if none of OPENAI_API_KEY,
  GEMINI_API_KEY, or GCP_NATIVE is configured.

- validate_neo4j_config(): called in cre_main.run() before
  --populate_neo4j_db. Exits if NEO4J_URL is not set.

The web validator is wired into create_app() and skipped when a custom
conf object is provided (CLI db_connect path) or when running in test
mode, so neither the CLI nor the test suite is affected.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Startup validation: abort early on missing critical configuration

1 participant