Skip to content

Redact restore diagnostics and clarify update validation failures - #22208

Merged
David Negstad (danegsta) merged 31 commits into
mainfrom
danegsta-update-restore-diagnostics
Nov 18, 2026
Merged

David Negstad (danegsta) merged 31 commits into
mainfrom
danegsta-update-restore-diagnostics

Conversation

@danegsta

@danegsta David Negstad (danegsta) commented Nov 12, 2026 •

Copy link
Copy Markdown
Member

Description

aspire update now captures native restore diagnostics following #22355, but those diagnostics can contain credential-bearing feed URLs that are persisted in the CLI log. This follow-up applies the existing NuGet redactor before stdout or stderr is buffered or logged, while preserving useful diagnostics for troubleshooting validation failures.

The redactor uses known sources from candidate and referenced-project NuGet configurations, plus RestoreAdditionalProjectSources values obtained during project evaluation. Raw evaluation diagnostics are suppressed so those source properties do not leak through the probes themselves. Restore diagnostics remain logged for success and failure, and are displayed only on failure.

The failure summary now includes the channel and project and explicitly states that the update was not applied.

Redaction scope

This reuses package-only polyglot restore redaction; it does not scan diagnostic text for unknown URLs or inspect restore graph files. Sources introduced only by restore-time targets, additive source changes after planning, and arbitrary non-source secrets are outside this change's coverage.

Stacked on #22207. Follows up on #22355. No new dependencies.

Validation

The following command passed 10/10 cases, covering project and file-based AppHosts, successful and failed restores, both output streams, root and referenced-project sources, evaluated additive sources, encoded credentials, probe suppression, and candidate feed configuration:

dotnet test --project tests/Aspire.Cli.Tests/Aspire.Cli.Tests.csproj --no-launch-profile -- --filter-method "*.UpdateAsync_RestoreDiagnosticsAreRedactedBeforeLoggingAndFailureDisplay" --filter-method "*.UpdateAsync_DryRunUsesAmbientEvaluationForImportedSdkAndColdCandidateRestore" --filter-not-trait "quarantined=true" --filter-not-trait "outerloop=true"

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

Allow aspire update --force to skip candidate graph restore for explicit .NET channel updates while retaining configuration conflict checks and confirmation prompts.

Co-authored-by: Copilot App <[email protected]>
Capture stdout and stderr from the validation restore that runs after applying candidate update steps, display them before the update is rolled back, and clarify that a failed validation restore means the update was not applied.

Co-authored-by: Copilot App <[email protected]>
Apply explicit channel updates without a validation restore. Add validation-only dry runs with temporary NuGet caches and durable adjacent backups, requiring separate consent before replacing recovery data.

Co-authored-by: Copilot App <[email protected]>
Preserve isolated restore settings alongside diagnostic output capture and exercise the failure case through dry-run validation.

Co-authored-by: Copilot App <[email protected]>
@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 -- 22208

Or

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

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

Failed restore diagnostics retain credential-bearing feed URLs in displayed output and persistent logs, requiring redaction before buffering and regression coverage for both paths.

1 open issue
1 file not reviewed
  • src/Aspire.Cli/Resources/UpdateCommandStrings.Designer.cs: Generated file
What changed in this PR

This PR makes failed aspire update validation restores diagnosable for .NET AppHosts, building on the dry-run workflow introduced in #22207.

Changes:

  • Captures restore stdout and stderr, displays them on failure, and logs the captured diagnostics at Debug level.
  • Revises the failure message to identify the channel and state that the update was not applied.
  • Extends failure-path tests to verify both output streams and refreshes localization resources.
File Description
tests/​Aspire.Cli.Tests/​Projects/​ProjectUpdaterTests.cs Verifies stdout and stderr from failed dry-run validation.
src/​Aspire.Cli/​Resources/​xlf/​UpdateCommandStrings.zh-Hant.xlf Refreshes the Traditional Chinese translation entry.
src/​Aspire.Cli/​Resources/​xlf/​UpdateCommandStrings.zh-Hans.xlf Refreshes the Simplified Chinese translation entry.
src/​Aspire.Cli/​Resources/​xlf/​UpdateCommandStrings.tr.xlf Refreshes the Turkish translation entry.
src/​Aspire.Cli/​Resources/​xlf/​UpdateCommandStrings.ru.xlf Refreshes the Russian translation entry.
src/​Aspire.Cli/​Resources/​xlf/​UpdateCommandStrings.pt-BR.xlf Refreshes the Brazilian Portuguese translation entry.
src/​Aspire.Cli/​Resources/​xlf/​UpdateCommandStrings.pl.xlf Refreshes the Polish translation entry.
src/​Aspire.Cli/​Resources/​xlf/​UpdateCommandStrings.ko.xlf Refreshes the Korean translation entry.
src/​Aspire.Cli/​Resources/​xlf/​UpdateCommandStrings.ja.xlf Refreshes the Japanese translation entry.
src/​Aspire.Cli/​Resources/​xlf/​UpdateCommandStrings.it.xlf Refreshes the Italian translation entry.
src/​Aspire.Cli/​Resources/​xlf/​UpdateCommandStrings.fr.xlf Refreshes the French translation entry.
src/​Aspire.Cli/​Resources/​xlf/​UpdateCommandStrings.es.xlf Refreshes the Spanish translation entry.
src/​Aspire.Cli/​Resources/​xlf/​UpdateCommandStrings.de.xlf Refreshes the German translation entry.
src/​Aspire.Cli/​Resources/​xlf/​UpdateCommandStrings.cs.xlf Refreshes the Czech translation entry.
src/​Aspire.Cli/​Resources/​UpdateCommandStrings.resx Revises the validation failure message and placeholder notes.
src/​Aspire.Cli/​Resources/​UpdateCommandStrings.Designer.cs Synchronizes the resource accessor’s documentation.
src/​Aspire.Cli/​Projects/​ProjectUpdater.cs Captures, logs, and displays restore diagnostics before rollback.

Review effort: Balanced

Reject non-interactive backup replacement before invoking extension prompts. Isolate initial project evaluations and in-process SDK acquisition, and cover real CLI validation, rollback, backup replacement and cold-cache failures in CI.

Co-authored-by: Copilot App <[email protected]>
@github-actions

This comment has been minimized.

Preserve restore diagnostics assertions while adopting the parent's dry-run test helper.

Co-authored-by: Copilot App <[email protected]>
Initialize the isolated package directory in clone coverage and exercise restore arguments with and without isolation.

Co-authored-by: Copilot App <[email protected]>
Use private leased directories under the Aspire home cache for validation packages and SDK acquisition scratch data, with permission and cleanup regression checks.

Co-authored-by: Copilot App <[email protected]>
Preserve configured-channel updates alongside validation-only dry runs, and align merged test expectations and helper call sites.

Co-authored-by: Copilot App <[email protected]>
Keep initial policy, project, reference, and central-property evaluation on ambient NuGet configuration and caches. Isolate candidate SDK acquisition, staged update subprocesses, and validation restore without introducing another import parser.

Cover imported SDK planning and rollback after both successful and failed cold validation, and keep the invocation-directory fixture's Aspire home separate.

Co-authored-by: Copilot App <[email protected]>
Keep Chromium installation on an Ubuntu release supported by the workflow's pinned Playwright 1.58.2 rather than ubuntu-latest's Ubuntu 26.04 image.

Co-authored-by: Copilot App <[email protected]>
Read the missing-dependency error code and library ID from project.assets.json instead of expecting native restore output in the CLI's redirected logs.

Co-authored-by: Copilot App <[email protected]>
Rename RestorePackagesDirectory to IsolatedRestorePackagesDirectory so the option's package-path, HTTP-cache bypass and forced-restore semantics remain explicit at call sites.

Co-authored-by: Copilot App <[email protected]>
Preserve display-only restore diagnostics with the renamed isolated restore option.

Co-authored-by: Copilot App <[email protected]>
@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.

🔵 Needs a closer look

The Windows test command emits a trailing space that the callback preserves, causing the stderr equality assertion to fail in both theory cases.

No open issues 🎉

1 previously missed issue

In code that hasn't changed since last review

Medium severity Windows diagnostic output includes an unexpected trailing space

tests/​Aspire.Cli.Tests/​DotNet/​ProcessExecutionFactoryEnvironmentTests.cs:33

On Windows, echo {diagnostic} 1>&2 includes the space before the redirection in the emitted text. The callback preserves that trailing space, so Assert.Equal([diagnostic], stderr) fails for both theory cases. Move the redirection before echo so the Windows script emits exactly the same diagnostic as the Unix script.

2 resolved since last review
1 file not reviewed
  • src/Aspire.Cli/Resources/UpdateCommandStrings.Designer.cs: Generated file

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.

@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

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.

🔵 Needs a closer look

Potential credential exposure in SDK-repair restore logs and Windows-specific test assertion failures require human assessment of security and verification reliability.

No open issues 🎉

1 file not reviewed
  • src/Aspire.Cli/Resources/UpdateCommandStrings.Designer.cs: Generated file

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.

@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

Tests selector

3 / 101 PR test projects · 4 PR jobs, from 23 changed files.

Selected PR test projects (3 / 101)

Aspire.Cli.EndToEnd.Tests, Aspire.Cli.Tests, Infrastructure.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

🔧 src/Aspire.Cli/Resources/UpdateCommandStrings.resx (changed source)
→ 1 directly: Infrastructure.Tests

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

🧪 tests/Aspire.Cli.Tests/Projects/ProjectUpdaterNuGetConfigurationTests.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/DotNet/DotNetAppHostRestorePreview.cs, src/Aspire.Cli/NuGet/BundleNuGetService.cs, src/Aspire.Cli/NuGet/NuGetClient.cs, src/Aspire.Cli/Projects/PrebuiltAppHostServer.cs, src/Aspire.Cli/Projects/ProjectUpdater.cs, src/Aspire.Cli/Resources/UpdateCommandStrings.Designer.cs, src/Aspire.Cli/Resources/UpdateCommandStrings.resx, src/Aspire.Cli/Resources/xlf/UpdateCommandStrings.cs.xlf, src/Aspire.Cli/Resources/xlf/UpdateCommandStrings.de.xlf, src/Aspire.Cli/Resources/xlf/UpdateCommandStrings.es.xlf, src/Aspire.Cli/Resources/xlf/UpdateCommandStrings.fr.xlf, src/Aspire.Cli/Resources/xlf/UpdateCommandStrings.it.xlf, src/Aspire.Cli/Resources/xlf/UpdateCommandStrings.ja.xlf, src/Aspire.Cli/Resources/xlf/UpdateCommandStrings.ko.xlf, src/Aspire.Cli/Resources/xlf/UpdateCommandStrings.pl.xlf, src/Aspire.Cli/Resources/xlf/UpdateCommandStrings.pt-BR.xlf, src/Aspire.Cli/Resources/xlf/UpdateCommandStrings.ru.xlf, src/Aspire.Cli/Resources/xlf/UpdateCommandStrings.tr.xlf, src/Aspire.Cli/Resources/xlf/UpdateCommandStrings.zh-Hans.xlf, src/Aspire.Cli/Resources/xlf/UpdateCommandStrings.zh-Hant.xlf, src/Aspire.Cli/Utils/PackageSourceRedactor.cs
• affected project Aspire.Cli
polyglot affected project Aspire.Cli
typescript-api-compat affected project Aspire.Cli

Selection computed for commit 58aea0c.

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

The review identifies no active issues with the credential-redaction and restore-diagnostics changes.

No open issues 🎉

1 file not reviewed
  • src/Aspire.Cli/Resources/UpdateCommandStrings.Designer.cs: Generated file

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.

@danegsta
David Negstad (danegsta) merged commit 79127e0 into main Nov 18, 2026
649 of 656 checks passed
@microsoft-github-policy-service microsoft-github-policy-service Bot added this to the 17.1 milestone Nov 18, 2026
@aspire-repo-bot

Copy link
Copy Markdown
Contributor

Pull request created: #2210

Generated by PR Documentation Check · copilot · auto · 26.2 AIC · ⌖ 1.17 AIC · ⊞ 7.4K

@aspire-repo-bot

Copy link
Copy Markdown
Contributor

📝 Documentation has been drafted in microsoft/aspire.dev#2210 targeting release/17.1.

Documented the new aspire update validation-restore failure message (channel + project, update not applied) and restore-diagnostics redaction scope in aspire-update.mdx. Signals: cli_resource_strings_changed (UpdateCommandStrings.resx FailedToRestoreAfterUpdateFormat reworded), pr_body_has_cli_flag_mention (PR body).

Note

This draft PR needs human review before merging.

David Negstad (danegsta) added a commit that referenced this pull request Nov 18, 2026
Jose Perez Rodriguez (joperezr) pushed a commit that referenced this pull request Nov 23, 2026
…22219)

Backport of #22182 to release/17.0

Also backports #22207, #22355, and #22208 using their distinct
squash-merge changes, without replaying the stacked PR history.

/cc @danegsta

## Description

C# AppHost updates can ignore configured channels, and failed restores
can block channel updates while hiding actionable diagnostics. Honor
configured channels, separate applying channel updates from `--dry-run`
validation, and log/display native restore diagnostics with best-effort
credential redaction.

Normal channel updates apply confirmed edits without requiring a
validation restore. Explicit `--dry-run` validation uses isolated caches
and restore outputs, then restores the original source files. Updates
without a selected channel retain their existing restore behavior. These
changes do not fix underlying dependency conflicts or MSBuild task DLL
locks.

Relates to #22214 and #22352.

**Release prerequisite:** This backport is intended for 17.0.1.
`release/17.0` still has `PatchVersion=0` although stable v17.0.0 is
published. Advance the release branch to the next unshipped servicing
version in a separate PR; no version bump is included here.

## Checklist

- Is this feature complete?
  - [x] Yes. Ready to ship.
  - [ ] No. Follow-up changes expected.
- Are you including unit tests for the changes and scenario tests if
relevant?
  - [x] 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
  - [x] No
- Does the change make any security assumptions or guarantees?
  - [x] Yes
    - If yes, have you done a threat model and had a security review?
      - [ ] Yes
      - [x] No
  - [ ] No

## Customer Impact

Customers updating C# AppHosts can have their configured channel ignored
or lose candidate updates when dependency conflicts cause restore to
fail, with no useful restore diagnostics. The combined fixes honor the
configured channel, let customers apply channel updates independently of
validation, and expose actionable restore errors. Credential-bearing
package source URLs are redacted on a best-effort basis before
diagnostics are buffered or logged.

## Testing

`./restore.sh` - passed (13 existing package vulnerability warnings, 0
errors).

`git diff --check 38e4ce6..HEAD` - passed. Each of the three added
commits has the same stable patch ID as its source squash commit.

Focused CLI unit run on macOS ARM64 - **788 passed, 2 failed, 2
skipped**:

```shell
MSBUILDTERMINALLOGGER=false dotnet test --project tests/Aspire.Cli.Tests/Aspire.Cli.Tests.csproj --no-launch-profile -- --filter-class '*.ProjectUpdater*' --filter-class '*.UpdateCommand*' --filter-class '*.ConfigSourceCommandTests' --filter-class '*.DotNetAppHostRestorePreviewTests' --filter-class '*.DotNetAppHostUpdateTransactionTests' --filter-class '*.DotNetCliRunnerTests' --filter-class '*.ProcessInvocationOptionsTests' --filter-class '*.NuGetClientTests' --filter-class '*.ProcessExecutionFactoryEnvironmentTests' --filter-class '*.PackageSourceRedactorTests' --filter-not-trait 'quarantined=true' --filter-not-trait 'outerloop=true'
```

Both failures were the native file-based restore theory, with
MSB4216/MSB4027 task-host errors caused by mixing the system .NET host
with the repository-local SDK. Rerunning only those cases with the
repository-local host on PATH **passed 2/2**, without code changes:

```shell
PATH="$PWD/.dotnet:$PATH" DOTNET_ROOT="$PWD/.dotnet" MSBUILDTERMINALLOGGER=false .dotnet/dotnet test --project tests/Aspire.Cli.Tests/Aspire.Cli.Tests.csproj --no-launch-profile -- --filter-method '*.UpdateAsync_FileBasedNativePackageMetadataEditsSourceAndRollsBackOnFailure' --filter-not-trait 'quarantined=true' --filter-not-trait 'outerloop=true'
```

Across the initial run and targeted retry, all **790 runnable cases
passed**. The two skips require Windows batch execution and a
case-sensitive filesystem, respectively.

E2E scenarios are included in the backport but were not run locally; CI
validation remains outstanding.

## Risk

Medium. This changes when C# channel updates restore and introduces
validation-only rollback and isolated caches/restore outputs. Updates
without a selected channel retain their restore behavior. Credential
redaction is best effort, not a security guarantee; logs should still be
checked before sharing. No supported library API changes or new
dependencies are introduced.

## Regression?

No.

---------

Co-authored-by: David Negstad <[email protected]>
Co-authored-by: Copilot App <[email protected]>
Co-authored-by: James Newton-King <[email protected]>
Co-authored-by: David Negstad <[email protected]>
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.

3 participants