fix(alembic): handle fileConfig parsing errors with user-friendly diagnostic #8288

Merged
HAL9000 merged 3 commits from bugfix/m3-error-handling-fileconfig-unhandled-exception into master 2026-06-02 07:57:28 +00:00

3 Commits

Author SHA1 Message Date
HAL9000 6aba1c37b8 fix(tests): resolve lint errors and step logic in tdd_fileconfig steps
CI / lint (pull_request) Successful in 1m0s
CI / quality (pull_request) Successful in 51s
CI / security (pull_request) Successful in 1m25s
CI / typecheck (pull_request) Successful in 1m47s
CI / push-validation (pull_request) Successful in 38s
CI / helm (pull_request) Successful in 40s
CI / build (pull_request) Successful in 47s
CI / unit_tests (pull_request) Successful in 6m24s
CI / docker (pull_request) Successful in 1m30s
CI / integration_tests (pull_request) Successful in 8m57s
CI / coverage (pull_request) Successful in 7m46s
CI / status-check (pull_request) Successful in 3s
- Add `from typing import Any` to fix F821 undefined name errors
- Remove spurious `# noqa: TID251` and `# noqa: C901` directives (RUF100)
- Use `_MIGRATIONS_DIR` absolute path in alembic.ini writer functions so
  `alembic current` actually loads the project env.py and exercises the
  fileConfig() error-handling path
- Add `CLEVERAGENTS_DATABASE_URL` to subprocess env for valid-config scenario
- Add `assert result.returncode != 0` check in stderr guidance step
- Apply ruff format (merged adjacent decorator string literals)

ISSUES CLOSED: #7874
2026-06-02 03:39:50 -04:00
HAL9000 68fd040e31 chore(steps): improve fileConfig error handling step readability (issue #7874)
Minor improvements to feature descriptions and docstrings for clarity.
No behavioral changes - all scenarios produce the same assertions.
2026-06-02 03:39:50 -04:00
HAL9000 7859a6c05b fix(alembic): handle fileConfig parsing errors with user-friendly diagnostic (#7874)
Wrapped the `fileConfig()` call in `src/cleveragents/infrastructure/database/migrations/env.py`
with a `try/except` block that catches malformed INI logging configuration and emits
a clear, user-actionable error message to stderr before exiting with code 1.

Includes:
- Error handling guard around fileConfig() in env.py (fileConfig can raise
  configparser.Error, KeyError, ValueError on malformed logging config)
- BDD/Behave feature file with 4 scenarios under `features/`
- Step definitions in `features/steps/` for isolated test coverage
- CHANGELOG.md entry under [Unreleased] Fixed section
- CONTRIBUTORS.md update for HAL 9000

ISSUES CLOSED: #7874

Signed-off-by: CleverThis <hal9000@cleverthis.com>
2026-06-02 03:39:50 -04:00