Repository navigation
Reject unknown arguments in aspire destroy - #21379
Conversation
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
|
🚀 Dogfood this PR with:
curl -fsSL https://raw.githubusercontent.com/microsoft/aspire/main/eng/scripts/get-aspire-cli-pr.sh | bash -s -- 21379Or
iex "& { $(irm https://raw.githubusercontent.com/microsoft/aspire/main/eng/scripts/get-aspire-cli-pr.ps1) } 21379" |
This comment has been minimized.
This comment has been minimized.
There was a problem hiding this comment.
🟡 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
--formatfor 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
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
|
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. |
This comment has been minimized.
This comment has been minimized.
|
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
|
Installed-CLI E2E coverage is added in df32899 and passes; the requested review thread is resolved. copilot-pull-request-reviewer, ready for another look. |
Tests selector2 / 100 PR test projects · 4 PR jobs, from 5 changed files. Selected PR test projects (2 / 100)
Selected PR jobs (4)
How these were chosen — grouped by what changed📦 affected project 🧪 🧪 🧪 Job reasons
Selection computed for commit |
|
Retrying the failed CI jobs for this pull request from the CI run attempt. The rerun is being tracked in the rerun attempt. |
|
Retrying the failed CI jobs for this pull request from the CI run attempt. The rerun is being tracked in the rerun attempt. |
|
Pull request created: #1975
|
|
📝 Documentation has been drafted in microsoft/aspire.dev#1975 targeting Updated Note This draft PR needs human review before merging. |
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>

Description
Reject unknown
aspire destroyoptions 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
Returns exit code 1 before AppHost discovery.
aspire destroy --helpnow showsaspire destroy [options];--list-steps --format jsonremains 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:
Passed: installed-CLI E2E verifies
destroy --forceexits 1 with the expected error before a sentinel AppHost executes; a safe empty-AppHost positive control proves the sentinel works.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 --checkand changed-code whitespace validation passed; two existing whitespace diagnostics inDoCommandTests.cs:252-253also occur on the main baseline and are unchanged. Full suite and local native-AOT publishing were not run.Checklist
<remarks />and<code />elements on your triple slash comments?