Skip to content

fix: --config flag ignored when placed before subcommand#322

Merged
privateip merged 1 commit intoitential:develfrom
AutomateIP:fix/config-flag-ignored-before-subcommand
Mar 4, 2026
Merged

fix: --config flag ignored when placed before subcommand#322
privateip merged 1 commit intoitential:develfrom
AutomateIP:fix/config-flag-ignored-before-subcommand

Conversation

@AutomateIP
Copy link
Contributor

Summary

  • Bug: itential-mcp --config file.conf <command> silently ignored the config file, defaulting to localhost:443
  • Root cause: --config was inherited via parents=[global_options_parser] on both the main parser and each subparser. When --config appeared before the subcommand, the main parser captured it, but the subparser overwrote it with None (its default)
  • Fix: Removed parents=[global_options_parser] from subparsers so --config is only parsed once by the main parser

Test plan

  • All 2335 tests pass
  • itential-mcp --config file.conf test now correctly reads the config file
  • Updated test_parse_args_config_file to use the correct argument ordering

🤖 Generated with Claude Code

The --config global option was added as a parent parser to both the main
parser and each subparser. When --config appeared before the subcommand
(e.g. `itential-mcp --config file.conf test`), the main parser captured
it correctly, but the subparser then overwrote it with its default (None),
causing the config file to never be loaded.

Removed `parents=[global_options_parser]` from subparsers so --config is
only parsed once by the main parser, preventing the overwrite.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@AutomateIP AutomateIP requested a review from a team as a code owner March 4, 2026 01:24
@privateip privateip merged commit 94cf703 into itential:devel Mar 4, 2026
4 checks passed
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.

2 participants