Skip to content

Reject unknown arguments in aspire destroy - #21379

Merged
Mitch Denny (mitchdenny) merged 4 commits into
mainfrom
fix/16327-destroy-unknown-options
Oct 29, 2026
Merged

Mitch Denny (mitchdenny) merged 4 commits into
mainfrom
fix/16327-destroy-unknown-options

Conversation

@spboyer

@spboyer Shayne Boyer (spboyer) commented Oct 28, 2026 •

Copy link
Copy Markdown
Member

Description

Reject unknown aspire destroy options and positional arguments before starting the AppHost, rather than silently running the destroy pipeline. Preserve existing destroy options, list-step JSON output, and argument forwarding for publish/deploy/do. No new dependencies or public API.

Fixes #16327

User-facing usage

aspire destroy --force
Unrecognized command or argument '--force'.

Returns exit code 1 before AppHost discovery. aspire destroy --help now shows aspire destroy [options]; --list-steps --format json remains supported.

Validation

Passed: 142 targeted tests covering unknown arguments, list-only format validation, rejection of numeric/composite format values, and case-insensitive JSON names in both syntaxes:

NO_COLOR=1 MSBUILDTERMINALLOGGER=false ./.dotnet/dotnet test \
  --project tests/Aspire.Cli.Tests/Aspire.Cli.Tests.csproj --no-launch-profile -- \
  --filter-class '*.DestroyCommandTests' --filter-class '*.PublishCommandTests' \
  --filter-class '*.DeployCommandTests' --filter-class '*.DoCommandTests' \
  --filter-class '*.PipelineCommandListStepsTests' --filter-class '*.BaseCommandTests' \
  --filter-not-trait 'quarantined=true' --filter-not-trait 'outerloop=true'

Passed: installed-CLI E2E verifies destroy --force exits 1 with the expected error before a sentinel AppHost executes; a safe empty-AppHost positive control proves the sentinel works.

./.dotnet/dotnet test --project tests/Aspire.Cli.EndToEnd.Tests/Aspire.Cli.EndToEnd.Tests.csproj \
  --no-launch-profile -- --filter-method '*.DestroyRejectsUnknownArgumentsBeforeStartingAppHost' \
  --filter-not-trait 'quarantined=true' --filter-not-trait 'outerloop=true'

E2E used CLI/packages and the Docker image from CI run 40770573465, with the container's user-level NuGet source remapped to the approved dotnet-public mirror for local connectivity. No repository infrastructure changed.

Three original regression cases and six format-value cases failed before their respective fixes. No deployed resources were touched. git diff --check and changed-code whitespace validation passed; two existing whitespace diagnostics in DoCommandTests.cs:252-253 also occur on the main baseline and are unchanged. Full suite and local native-AOT publishing were not run.

Checklist

  • Is this feature complete?
    • Yes. Ready to ship.
    • No. Follow-up changes expected.
  • Are you including unit tests for the changes and scenario tests if relevant?
    • Yes
    • No
  • Did you add public API?
    • Yes
      • If yes, did you have an API Review for it?
        • Yes
        • No
      • Did you add <remarks /> and <code /> elements on your triple slash comments?
        • Yes
        • No
    • No
  • Does the change make any security assumptions or guarantees?
    • Yes
      • If yes, have you done a threat model and had a security review?
        • Yes
        • No
    • No

Reject unmatched destroy arguments before AppHost execution while preserving list-step JSON output and forwarding for other pipeline commands.

Co-authored-by: Copilot <[email protected]>
Copilot-Session: ec985093-e9b2-4cb1-b459-4b6f2cd9c022
Address pre-review feedback by rejecting --format on destructive invocations and covering both option syntaxes.

Co-authored-by: Copilot <[email protected]>
Copilot-Session: ec985093-e9b2-4cb1-b459-4b6f2cd9c022
@github-actions

Copy link
Copy Markdown
Contributor

🚀 Dogfood this PR with:

⚠️ WARNING: Do not do this without first carefully reviewing the code of this PR to satisfy yourself it is safe.

curl -fsSL https://raw.githubusercontent.com/microsoft/aspire/main/eng/scripts/get-aspire-cli-pr.sh | bash -s -- 21379

Or

  • Run remotely in PowerShell:
iex "& { $(irm https://raw.githubusercontent.com/microsoft/aspire/main/eng/scripts/get-aspire-cli-pr.ps1) } 21379"

@github-actions

This comment has been minimized.

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 format option accepts numeric values such as 1 instead of rejecting anything other than table or json.

1 open issue
What changed in this PR

This PR addresses #16327 by rejecting unknown aspire destroy arguments before AppHost discovery, while preserving argument forwarding for other pipeline commands.

Changes:

  • Enables strict argument parsing for destroy.
  • Registers --format for destroy’s list-step output and rejects it without --list-steps.
  • Adds regression tests for unknown arguments and both JSON format syntaxes.
File Description
tests/​Aspire.Cli.Tests/​Commands/​DoCommandTests.cs Adds destroy list-step JSON cases and expected AppHost arguments.
tests/​Aspire.Cli.Tests/​Commands/​DestroyCommandTests.cs Tests unknown-argument rejection and list-only format validation.
src/​Aspire.Cli/​Commands/​PipelineCommandBase.cs Adds a registered format option and reads it during list-step resolution.
src/​Aspire.Cli/​Commands/​DestroyCommand.cs Enables strict parsing and validates format usage.

Review effort: Balanced

@spboyer
Shayne Boyer (spboyer) marked this pull request as draft October 28, 2026 21:12
Reuse the existing name-only format parser so registered options reject numeric and composite enum values while preserving case-insensitive names. Add regression coverage before AppHost startup.

Co-authored-by: Copilot <[email protected]>
Copilot-Session: ec985093-e9b2-4cb1-b459-4b6f2cd9c022
@spboyer
Shayne Boyer (spboyer) marked this pull request as ready for review October 28, 2026 21:16
@spboyer
Shayne Boyer (spboyer) requested a balanced review from Copilot October 28, 2026 21:16
@spboyer

Copy link
Copy Markdown
Member Author

Addressed the format-validation feedback in 542dcc2: 142 targeted tests passed and both pre-review passes are clean. copilot-pull-request-reviewer — ready for another look.

@github-actions

This comment has been minimized.

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 installed CLI lacks an end-to-end regression verifying that destroy --force exits with an unrecognized-argument error without starting the AppHost.

1 open issue
1 resolved since last review

Review effort: Balanced

@spboyer
Shayne Boyer (spboyer) marked this pull request as draft October 28, 2026 22:13
@github-actions

Copy link
Copy Markdown
Contributor

Retrying the failed CI jobs for this pull request from the CI run attempt. The rerun is being tracked in the rerun attempt.

Assert unknown-option exit code and diagnostic before a sentinel AppHost starts, then verify the sentinel using an empty-AppHost positive control. Bound CLI invocations to avoid leaving a process running after timeout.

Co-authored-by: Copilot <[email protected]>
Copilot-Session: ec985093-e9b2-4cb1-b459-4b6f2cd9c022
@spboyer
Shayne Boyer (spboyer) marked this pull request as ready for review October 28, 2026 22:33
@spboyer

Copy link
Copy Markdown
Member Author

Installed-CLI E2E coverage is added in df32899 and passes; the requested review thread is resolved. copilot-pull-request-reviewer, ready for another look.

@github-actions

Copy link
Copy Markdown
Contributor

Tests selector

2 / 100 PR test projects · 4 PR jobs, from 5 changed files.

Selected PR test projects (2 / 100)

Aspire.Cli.EndToEnd.Tests, Aspire.Cli.Tests

Selected PR jobs (4)

cli-starter-validation, extension-e2e, polyglot, typescript-api-compat


How these were chosen — grouped by what changed

📦 affected project Aspire.Cli
→ 1 test: Aspire.Cli.EndToEnd.Tests

🧪 tests/Aspire.Cli.EndToEnd.Tests/EmptyAppHostTemplateTests.cs (changed test)
→ 1 directly: Aspire.Cli.EndToEnd.Tests

🧪 tests/Aspire.Cli.Tests/Commands/DestroyCommandTests.cs (changed test)
→ 1 directly: Aspire.Cli.Tests

🧪 tests/Aspire.Cli.Tests/Commands/DoCommandTests.cs (changed test)
→ 1 directly: Aspire.Cli.Tests

Job reasons

Job Triggered by
cli-starter-validation affected project Aspire.Cli
extension-e2e • src/Aspire.Cli/Commands/DestroyCommand.cs, src/Aspire.Cli/Commands/PipelineCommandBase.cs
• affected project Aspire.Cli
polyglot affected project Aspire.Cli
typescript-api-compat affected project Aspire.Cli

Selection computed for commit df32899.

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.

🟢 Approval recommended

No active review issues remain.

No open issues 🎉

1 resolved since last review

Review effort: Balanced

@github-actions

Copy link
Copy Markdown
Contributor

Retrying the failed CI jobs for this pull request from the CI run attempt. The rerun is being tracked in the rerun attempt.

@github-actions

Copy link
Copy Markdown
Contributor

Retrying the failed CI jobs for this pull request from the CI run attempt. The rerun is being tracked in the rerun attempt.

@mitchdenny
Mitch Denny (mitchdenny) merged commit 58408e0 into main Oct 29, 2026
606 of 613 checks passed
@microsoft-github-policy-service microsoft-github-policy-service Bot added this to the 17.0 milestone Oct 29, 2026
@aspire-repo-bot

Copy link
Copy Markdown
Contributor

Pull request created: #1975

Generated by PR Documentation Check · copilot · auto · 23.4 AIC · ⌖ 1.14 AIC · ⊞ 7.1K

@aspire-repo-bot

Copy link
Copy Markdown
Contributor

📝 Documentation has been drafted in microsoft/aspire.dev#1975 targeting release/17.0.

Updated aspire-destroy.mdx: synopsis is now aspire destroy [options], removed the -- passthrough option, and added an "Unknown arguments" section (exit code 1, Unrecognized command or argument '--force'.). Signals: cli_command_file_changed (DestroyCommand.cs), cli_option_added (PipelineCommandBase.cs --format), pr_body_has_cli_flag_mention and pr_body_has_user_facing_section (PR body aspire destroy --force example).

Note

This draft PR needs human review before merging.

David Pine (IEvangelist) pushed a commit to microsoft/aspire.dev that referenced this pull request Nov 13, 2026
Documents changes from microsoft/aspire#21379

Author: ``@spboyer``

Targeting `release/17.0` based on the source PR milestone `17.0` (exact
match).

## Why
`aspire destroy` now rejects unknown options and positional arguments
before AppHost discovery (exit code 1) instead of silently running the
destroy pipeline. The docs still described a `--` passthrough for
AppHost arguments.

## Changes (updated page)
-
`src/frontend/src/content/docs/reference/cli/commands/aspire-destroy.mdx`:
synopsis now `aspire destroy [options]`, removed the `--` option, added
an "Unknown arguments" section with the example error.

> Generated by [PR Documentation
Check](https://github.com/microsoft/aspire/actions/runs/40802859999) for
#21379 · copilot · auto · 23.4 AIC · ⌖ 1.14 AIC · ⊞ 7.1K ·
[◷](https://github.com/search?q=repo%3Amicrosoft%2Faspire.dev+%22gh-aw-workflow-id%3A+pr-docs-check%22&type=pullrequests)

<!-- gh-aw-agentic-workflow: PR Documentation Check, engine: copilot,
model: auto, id: 40802859999, workflow_id: pr-docs-check, run:
https://github.com/microsoft/aspire/actions/runs/40802859999 -->

<!-- gh-aw-workflow-id: pr-docs-check -->
<!-- gh-aw-workflow-call-id: microsoft/aspire/pr-docs-check -->

Co-authored-by: aspire-repo-bot[bot] <268009190+aspire-repo-bot[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[AspireE2E] aspire destroy: with unknown flags, it will execute successfully without any CLI error.

3 participants