Skip to content

FIX: resolve config-relative paths from config file directory#1650

Open
romanlutz wants to merge 1 commit intomicrosoft:mainfrom
romanlutz:fix/config-relative-path-resolution
Open

FIX: resolve config-relative paths from config file directory#1650
romanlutz wants to merge 1 commit intomicrosoft:mainfrom
romanlutz:fix/config-relative-path-resolution

Conversation

@romanlutz
Copy link
Copy Markdown
Contributor

Summary

Resolve relative initialization_scripts and env_files paths from the configuration file's directory when loading YAML config files, instead of from the caller's working directory.

Problem

ConfigurationLoader currently resolves relative paths from Path.cwd(). When a config file lives in another directory, values like ./scripts/init.py point to the wrong location.

Approach

Eagerly resolve relative paths to absolute in from_yaml_file() — no hidden state, no plumbing through load_with_overrides. CLI path overrides continue to resolve from CWD as expected.

This is a simplified alternative to #1502.

Validation

  • pytest tests/unit/setup/test_configuration_loader.py — 51 tests pass
  • Pre-commit hooks (ruff, mypy) pass

@romanlutz romanlutz changed the title fix: resolve config-relative paths from config file directory FIX: resolve config-relative paths from config file directory Apr 24, 2026
Relative initialization_scripts and env_files paths in YAML config files
are now eagerly resolved against the config file's directory at load time
in from_yaml_file(), rather than deferring to CWD at resolve time.

This fixes the bug where ./scripts/init.py in a config file at
/project/config/pyrit.yaml would incorrectly resolve from the caller's
working directory instead of /project/config/.

CLI path overrides continue to resolve from CWD as expected.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@romanlutz romanlutz force-pushed the fix/config-relative-path-resolution branch from 332a745 to dc570e8 Compare April 24, 2026 05:53
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.

1 participant