Skip to content

Feat/cfg 005 validate config paths#583

Merged
chernistry merged 2 commits into
sipyourdrink-ltd:mainfrom
Beledarian:feat/cfg-005-validate-config-paths
Apr 8, 2026
Merged

Feat/cfg 005 validate config paths#583
chernistry merged 2 commits into
sipyourdrink-ltd:mainfrom
Beledarian:feat/cfg-005-validate-config-paths

Conversation

@Beledarian

Copy link
Copy Markdown
Contributor

What

Add startup validation for config-referenced file paths (context_files, agent_catalog).

Why

Fixes #303 - Config paths that don't exist cause mid-run failures. This validates all paths during startup with clear error messages.

How

  • New config_path_validation.py module with validate_config_paths() and check_config_paths()
  • Called in bootstrap.py after preflight_checks(), before orchestration starts
  • Error format: context_files: 'docs/DESIGN.md' does not exist
  • Exits with SystemExit(1) and actionable BernsteinError on failure

Checklist

  • uv run ruff check src/ passes
  • uv run pyright src/ passes
  • uv run python scripts/run_tests.py -x passes (Windows env issue - resource module unavailable)
  • New code has type hints
  • Docs updated if needed (N/A - inline docstrings added)

Add startup validation for file paths referenced in bernstein.yaml:
- context_files must exist and be regular files
- agent_catalog (if set) must exist and be a directory

If any path is missing, the run fails immediately with a clear error:
  context_files: 'docs/DESIGN.md' does not exist

Implementation:
- New module: src/bernstein/core/config_path_validation.py
- Integration: Called in bootstrap.py after preflight_checks()
- Handles both relative and absolute paths consistently
- Uses BernsteinError for actionable error messages

Test coverage includes valid/invalid paths, absolute paths, directories
vs files, and multiple error aggregation.

Fixes #303
Address review feedback:
- Use handle_cli_error() instead of manual print() + SystemExit
- Use ExitCode.CONFIG (3) for config validation failures
- Improve error message wording to cover both missing and wrong-type cases
@kilo-code-bot

kilo-code-bot Bot commented Apr 7, 2026

Copy link
Copy Markdown

Code Review Summary

Status: No Issues Found | Recommendation: Merge

Files Reviewed (3 files)
  • src/bernstein/core/bootstrap.py - New import and function call added
  • src/bernstein/core/config_path_validation.py - New module with validation logic
  • tests/unit/test_config_path_validation.py - Comprehensive test coverage

Reviewed by grok-code-fast-1 · 131,139 tokens

@sonarqubecloud

sonarqubecloud Bot commented Apr 7, 2026

Copy link
Copy Markdown

@chernistry chernistry left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Solid implementation — clean dataclasses, comprehensive tests (27 cases), proper error messaging. Thanks for the contribution! 👍

@chernistry chernistry merged commit 76671f4 into sipyourdrink-ltd:main Apr 8, 2026
3 checks passed
@Beledarian

Copy link
Copy Markdown
Contributor Author

Glad i could help :)

chernistry added a commit that referenced this pull request Apr 30, 2026
…paths

Feat/cfg 005 validate config paths
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Validate all file paths in config exist before run starts

2 participants