Skip to content

fix(cli): do not glob-expand arguments on Windows, so --skill '*' reaches APM - #4408

Merged
Daniel Meppiel (danielmeppiel) merged 4 commits into
mainfrom
danielmeppiel-windows-expand-args
Nov 21, 2026
Merged

Daniel Meppiel (danielmeppiel) merged 4 commits into
mainfrom
danielmeppiel-windows-expand-args

Conversation

@danielmeppiel

Copy link
Copy Markdown
Collaborator

Description

On Windows, Click glob-expands sys.argv inside the process (windows_expand_args=True by default). So apm install <pkg> --skill '*' received the current directory's file names (apm.yml, apm_modules, apm.lock.yaml) instead of * and failed. Shell quoting cannot prevent it. Found by the Windows lifecycle journeys (J04 step 4).

  • src/apm_cli/cli.py: main() calls cli(obj={}, windows_expand_args=False).
  • tests/unit/test_cli_encoding.py: new test_main_does_not_glob_expand_arguments_on_windows asserts that main() disables the expansion. It fails without the fix.
  • tests/unit/test_cli_sigterm.py and tests/integration/test_tls_trust.py: their fake_cli stubs accept the extra keyword.

No other command relies on the expansion. The only variadic arguments (install, update, deps, approve, uninstall) take package specs, not file paths, and the only documented glob is --skill '*' (consumer/install-packages.md, getting-started/coming-from.md, reference/cli/install.md, reference/package-types.md). install/argv.py already reads the raw sys.argv for -- handling, so this also makes the two views agree.

Issue and approved scope

Issue: Fixes #4407

Human scope-approval comment: the 0.37 steward ruling relayed by the Stream T lead (Windows journeys triage; every bug found is 0.37 scope).

Does this PR complete the issue, or what remains? It completes it.

Type of change

  • Bug fix
  • New feature
  • Documentation
  • Maintenance / refactor

Testing

  • Tested locally
  • All existing tests pass
  • Added tests for new functionality (if applicable)

Results (local, off main):

  • pytest tests/unit/test_cli_encoding.py tests/unit/test_cli_sigterm.py tests/integration/test_tls_trust.py: 35 passed.
  • The new test fails without the change (1 failed) and passes with it.
  • ruff check / format: clean.

Changelog

  • One line in one section under ## [Unreleased] in CHANGELOG.md.
  • N/A -- internal-only change (CI, tests, refactor).

Spec conformance (OpenAPM v0.1)

  • N/A -- this PR does not change OpenAPM-observable behaviour.

@danielmeppiel Daniel Meppiel (danielmeppiel) added this to the 0.37.0 milestone Nov 20, 2026
Copilot AI balanced review requested due to automatic review settings November 20, 2026 16:26
Co-authored-by: copilot-swe-agent[bot] <[email protected]>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Changes recommended

The new invocation breaks the CLI with supported Click 8.0.0, and Windows path expansion and the documented sentinel command also have unresolved issues.

3 open issues
What changed in this PR

This PR targets #4407 by changing APM’s Click entry point so Windows wildcard skill selectors reach the install command literally instead of expanding into directory contents.

Changes:

  • Disables Click’s automatic Windows argument expansion.
  • Adds an entry-point regression test and adapts existing CLI test stubs.
  • Records the Windows skill-reset fix in the changelog.
File Description
tests/​unit/​test_cli_sigterm.py Updates the SIGTERM test stub to accept additional keywords.
tests/​unit/​test_cli_encoding.py Checks that main() disables Windows argument expansion.
tests/​integration/​test_tls_trust.py Updates the TLS bootstrap test stub for the new keyword.
src/​apm_cli/​cli.py Disables Windows argument expansion when invoking Click.
CHANGELOG.md Documents the Windows wildcard skill-reset fix.

Review effort: Balanced

Comment thread src/apm_cli/cli.py
cli(obj={})
# Click glob-expands argv on Windows by default, so `--skill '*'` became
# the current directory's file names (#4407). APM never wants that.
cli(obj={}, windows_expand_args=False)
Comment thread CHANGELOG.md

### Fixed

- Windows: `apm install --skill '*'` resets to every skill again instead of receiving the current directory's file names. (#4408)
Comment thread src/apm_cli/cli.py
cli(obj={})
# Click glob-expands argv on Windows by default, so `--skill '*'` became
# the current directory's file names (#4407). APM never wants that.
cli(obj={}, windows_expand_args=False)
Daniel Meppiel (danielmeppiel) added a commit that referenced this pull request Nov 20, 2026
… so --skill '*' reaches APM

Co-authored-by: Copilot App <[email protected]>
… probe, not owner patches (#4407)

Co-authored-by: copilot-swe-agent[bot] <[email protected]>
Daniel Meppiel (danielmeppiel) added a commit that referenced this pull request Nov 20, 2026
@danielmeppiel
Daniel Meppiel (danielmeppiel) merged commit 6edc3fa into main Nov 21, 2026
1 check passed
@danielmeppiel
Daniel Meppiel (danielmeppiel) deleted the danielmeppiel-windows-expand-args branch November 21, 2026 05:24
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.

apm install --skill '*' expands to file names on Windows

2 participants