Skip to content

fix(cli): skip update check for unknown subcommands to fail fast#1541

Open
maro114510 wants to merge 1 commit into
microsoft:mainfrom
maro114510:fix/fail-fast-invalid-command
Open

fix(cli): skip update check for unknown subcommands to fail fast#1541
maro114510 wants to merge 1 commit into
microsoft:mainfrom
maro114510:fix/fail-fast-invalid-command

Conversation

@maro114510
Copy link
Copy Markdown

Thank you for maintaining this project. I opened this PR to fix a small issue I noticed.

Description

The update check ran in the CLI group handler, which Click invokes before resolving the subcommand name.
As a result, even a typo like apm updsate would block on a GitHub API call (synchronous, up to 2 s timeout) before the No such command error was shown.
The docstring said "non-blockingly" but the call was fully synchronous.

The guard ctx.invoked_subcommand in cli.commands is the same dict lookup Click uses internally when resolving commands, so there's no duplication of logic—just an early check.
One side effect: bare apm with no subcommand also skips the check now (invoked_subcommand is None), which is intentional since there's nothing to execute.

Type of change

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

Testing

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

@maro114510
Copy link
Copy Markdown
Author

@microsoft-github-policy-service agree

@maro114510 maro114510 marked this pull request as ready for review May 29, 2026 05:56
Copilot AI review requested due to automatic review settings May 29, 2026 05:56
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Note

Copilot was unable to run its full agentic suite in this review.

This PR updates the CLI’s update-notification behavior so it only runs for recognized subcommands, and adds integration tests to verify update checks are skipped for invalid/unknown commands.

Changes:

  • Gate _check_and_notify_updates() behind a “known subcommand” check in the CLI entrypoint.
  • Add integration tests covering invalid command, valid command, and no-subcommand scenarios.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
tests/integration/test_version_notification.py Adds integration tests ensuring the update check is skipped for invalid/unknown commands and when no subcommand is provided.
src/apm_cli/cli.py Changes update-check gating logic to run only when a recognized subcommand is invoked.

Comment thread src/apm_cli/cli.py
Comment on lines +67 to 69
# Check for updates only for known commands; skip on invalid input to fail fast.
if not ctx.resilient_parsing and ctx.invoked_subcommand in cli.commands:
_check_and_notify_updates()
danielmeppiel added a commit to danielmeppiel/genesis that referenced this pull request May 29, 2026
…S discipline

Dispatched v0.3+ panel against microsoft/apm#1541 (+41/-2, 2 files, small CLI fix).

Results:
- Executor cost: ~$0.21 (vs $2.85 on PR #1424)
- Per-kLoC: $5.12 (vs $1.15 baseline) — fixed Sonnet-executor overhead
  dominates at small scale (~93% of total cost)
- Panel cost shape holds in dollar terms; per-kLoC ratio inverted
- Arbiter trigger correctly did NOT fire (0 BLOCKERs)

KEY EMPIRICAL VALIDATION of v0.3.4 PER-LENS DIFFERENTIATION:
The executor reflected per-lens against the CAPABILITY PROFILE template
and concluded 4/5 lenses genuinely TRIVIAL, but security lens was
INADEQUATE on TRIVIAL/Haiku — it surfaced a real MEDIUM bypass concern
but could not validate it without out-of-diff function body access.

This empirically generates the per-element justification the v0.3.4
corpus requires architects to record at design time. Recommended carve-out:
'Security lens uses Haiku when all referenced functions are in-diff;
escalates to REVIEWER with tool access when it must reason about
out-of-diff internals.'

Implication for PR #1424: security lens was likely mis-bound to TRIVIAL.
The blocker false-positive (_substitute_plugin_root alleged undefined,
refuted only via out-of-diff gh api lookup) is consistent with TRIVIAL-
class inadequacy on cross-file reasoning. A v0.3.4 re-architect would
correctly bind security to REVIEWER, expected cost delta +$0.50-1.00
per run with measurable security finding fidelity improvement.

REPORT updated with multi-scenario section (small-PR + different-skill).
Deferral list narrowed: full S1-S5 × {v0.2,v0.3+} matrix remains follow-up.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
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