NewMayur opened a new pull request, #68451:
URL: https://github.com/apache/airflow/pull/68451

   ## Summary
   Currently, any typos or unrecognized sections/options inside `airflow.cfg` 
fail silently or cause unexpected fallback behaviors without warning the user. 
This PR introduces a JSON Schema generator to publish a formal schema of the 
configurations and a pre-commit validation hook to prevent invalid or 
misspelled options from being committed.
   
   ## Technical Approach
   1. **Schema Generator**: Created 
`airflow-core/src/airflow/config_templates/generate_schema.py` which parses 
`config.yml` statically and produces a Draft-07 JSON Schema at 
`airflow-core/src/airflow/config_templates/schema.json`. Suffixes for sensitive 
variables (`_cmd`, `_secret`) are automatically handled.
   2. **Validator**: Created `scripts/ci/pre_commit/validate_airflow_config.py` 
which reads `.cfg` files, casts parsed values into their expected schema types, 
and validates the config against `schema.json` using `jsonschema`.
   3. **Pre-commit Integration**: Registered the `validate-airflow-config` hook 
in `.pre-commit-config.yaml` to run during static checks.
   
   ## Files Modified & Created
   * **Created**: `airflow-core/src/airflow/config_templates/generate_schema.py`
   * **Created**: `airflow-core/src/airflow/config_templates/schema.json`
   * **Created**: `scripts/ci/pre_commit/validate_airflow_config.py`
   * **Modified**: `.pre-commit-config.yaml`
   
   ## Verification Executed
   * Tested schema generator in local virtual env `.venv`.
   * Executed the validation script against valid configurations (passed 
successfully) and configurations containing typos or invalid sections 
(correctly blocked and reported).
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to