Skip to content

fix(cli): forward --config flag to all load_config call sites - #478

Merged
ajianaz merged 1 commit into
developfrom
fix/config-flag-not-forwarded
Aug 4, 2026
Merged

ajianaz merged 1 commit into
developfrom
fix/config-flag-not-forwarded

Conversation

@ajianaz

@ajianaz ajianaz commented Aug 4, 2026

Copy link
Copy Markdown
Collaborator

What

The global --config flag (CORA_CONFIG env) was silently ignored by 5 commands because they called load_config(None, ...) instead of forwarding the user-provided config path.

Why

Users running cora config show --config /path/to/custom.yaml would get default config instead of their specified file — a silent failure with no error message. Same for config validate, debt, index, and dead-code.

Root cause: GlobalOptions.config was defined as a global = true clap flag (main.rs:54), but multiple match arms in main() and helper functions in config_cmd.rs/debt.rs hardcoded None for the cli_config_path parameter.

Changes

  • config_cmd.rs: execute_config_show() and execute_config_validate() now accept config_path: Option<&str>. Validate also uses --config path for raw file inspection (fixes cora review finding).
  • debt.rs: DebtOptions gains config_path field. execute_debt() forwards it to load_config.
  • main.rs: All 5 call sites now forward cli.global.config.as_deref():
    1. cora config show
    2. cora config validate
    3. cora debt
    4. cora index (skip pattern loading)
    5. cora dead-code (entry_point_patterns)

Testing

  • cargo test --bin cora — 776 passed, 0 failed
  • cargo test --test * — 22 passed, 0 failed
  • cargo clippy -- -D warnings — clean
  • cora review (pre-commit) — No issues found
  • Manual: cora config validate --config /tmp/test.yaml correctly reads custom config (Model: test-model-from-config vs default glm-5.2)

The global --config flag (CORA_CONFIG env) was silently ignored by
5 commands because they called load_config(None, ...) instead of
forwarding the user-provided config path.

Affected commands:
- cora config show        (config_cmd.rs)
- cora config validate    (config_cmd.rs)
- cora debt               (debt.rs)
- cora index              (main.rs - skip pattern loading)
- cora dead-code          (main.rs - entry_point_patterns)

Fix: thread cli.global.config.as_deref() through every call site.
DebtOptions gains a config_path field to receive the global flag.
@ajianaz
ajianaz force-pushed the fix/config-flag-not-forwarded branch from c844421 to d70fd2b Compare August 4, 2026 10:10
@ajianaz
ajianaz merged commit b76daf4 into develop Aug 4, 2026
13 checks passed
@ajianaz
ajianaz deleted the fix/config-flag-not-forwarded branch August 4, 2026 10:41
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