feat: validate critical config at startup and abort with clear messages#852
Open
shiwani42 wants to merge 1 commit intoOWASP:mainfrom
Open
feat: validate critical config at startup and abort with clear messages#852shiwani42 wants to merge 1 commit intoOWASP:mainfrom
shiwani42 wants to merge 1 commit intoOWASP:mainfrom
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #851
What changed
Added
application/validate_config.pywith three focused validators:validate_web_config(mode)Called from
create_app()when running in web server mode. Checks thatGOOGLE_CLIENT_SECRETandGOOGLE_CLIENT_IDare set and exits with a clear error if either is missing andNO_LOGINis not set. Logs warnings whenNEO4J_URLorREDIS_URLare absent. Skipped entirely in test/testing mode and when a customconfobject is provided (CLIdb_connectpath).validate_embeddings_config()Called in
cre_main.run()immediately before--generate_embeddings. Exits if none ofOPENAI_API_KEY,GEMINI_API_KEY, orGCP_NATIVEis configured.validate_neo4j_config()Called in
cre_main.run()immediately before--populate_neo4j_db. Exits ifNEO4J_URLis not set.Tests
13 new tests in
application/tests/validate_config_test.pycovering:NO_LOGINis setNEO4J_URLbefore Neo4j population