Skip to content

feat: improve environment validation and startup safety (fixes #167) - #189

Open
get-D wants to merge 2 commits into
c2siorg:mainfrom
get-D:feat/config-validation-error-handling
Open

feat: improve environment validation and startup safety (fixes #167)#189
get-D wants to merge 2 commits into
c2siorg:mainfrom
get-D:feat/config-validation-error-handling

Conversation

@get-D

@get-D get-D commented Mar 31, 2026

Copy link
Copy Markdown

Description

This PR resolves Issue #167 by improving how the application handles environment configuration during startup and by completing missing contribution guidelines.


Why this change?

Fail-fast startup (Fixes #167)
Previously, the application initialized heavy dependencies (like LangChain) before validating required environment variables. This could lead to unclear errors and unstable startup behavior when configuration was missing.

This PR introduces a fail-fast approach—environment variables are now validated at the very beginning, ensuring the app stops immediately with clear, actionable error messages if something is misconfigured.

Improved contributor guidance
The CONTRIBUTING.md file had incomplete sections. These have now been filled to provide clear standards for code style and commit practices.


What’s changed?

🔹 app.py

  • Refactored startup flow to call validate_env() before importing heavy dependencies

🔹 config/validator.py

  • Added detailed, user-friendly error messages for missing variables
  • Introduced .env file existence check for easier debugging
  • Clarified priority: Environment Variables > .env file

🔹 CONTRIBUTING.md

  • Completed Styleguides section (PEP 8 + Conventional Commits)
  • Added AI contribution attribution guidelines (Assisted-By / Generated-By)

🔹 tests/test_config_validation.py

  • Updated to cover:
    • Specific missing variable errors
    • Missing .env file scenario

Verification

✅ Automated Tests

  • Updated and validated test_config_validation.py
  • (Full test suite pending local dependency build fixes)

✅ Manual Testing

  • Verified clear error when .env is missing or renamed
  • Confirmed accurate detection and reporting of missing environment variables

get-D added 2 commits March 27, 2026 02:02
- Refactored app.py to validate configuration before heavy imports.
- Enhanced validator.py with better error messaging and .env existence checks.
- Completed CONTRIBUTING.md styleguides and AI policy labeling.
- Updated tests to match new validation logic and robustness.

Generated-By: Antigravity
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.

# Enhancement: Add Startup Configuration Validation and Structured JSON Error Handling

1 participant