Repository navigation
Fix malformed secrets diagnostics and side-effect-free path lookup - #21323
Conversation
Report invalid JSON with the secrets file location and repair guidance without changing its contents. Resolve environment secret paths without loading or migrating stores. Fixes #21322 Co-authored-by: Copilot App <[email protected]>
|
🚀 Dogfood this PR with:
curl -fsSL https://raw.githubusercontent.com/microsoft/aspire/main/eng/scripts/get-aspire-cli-pr.sh | bash -s -- 21323Or
iex "& { $(irm https://raw.githubusercontent.com/microsoft/aspire/main/eng/scripts/get-aspire-cli-pr.ps1) } 21323" |
This comment has been minimized.
This comment has been minimized.
There was a problem hiding this comment.
🟡 Changes recommended
Secret deletion still bypasses the actionable diagnostic when malformed legacy JSON coexists with a valid canonical Development store.
1 open issue
1 file not reviewed
src/Aspire.Cli/Resources/SecretCommandStrings.Designer.cs: Generated file
What changed in this PR
This PR addresses #21322 by separating CLI secrets-path lookup from data loading and adding actionable diagnostics for malformed secrets JSON.
Changes:
- Resolves
secret pathwithout loading, importing, migrating, or initializing secrets. - Adds file-specific JSON diagnostics with repair guidance and localization resources.
- Adds regression coverage for malformed stores, side-effect-free lookup, and correctly escaped backslashes; documents the output contract.
| File | Description |
|---|---|
| tests/Aspire.Cli.Tests/Commands/SecretCommandTests.cs | Tests diagnostics, path lookup, and backslash round trips. |
| src/Aspire.Cli/Secrets/InvalidSecretsFileException.cs | Formats file-specific JSON errors. |
| src/Aspire.Cli/Secrets/AspireSecretsStoreResolver.cs | Separates path lookup and wraps parsing failures. |
| src/Aspire.Cli/Resources/xlf/SecretCommandStrings.zh-Hant.xlf | Adds diagnostic translation entry. |
| src/Aspire.Cli/Resources/xlf/SecretCommandStrings.zh-Hans.xlf | Adds diagnostic translation entry. |
| src/Aspire.Cli/Resources/xlf/SecretCommandStrings.tr.xlf | Adds diagnostic translation entry. |
| src/Aspire.Cli/Resources/xlf/SecretCommandStrings.ru.xlf | Adds diagnostic translation entry. |
| src/Aspire.Cli/Resources/xlf/SecretCommandStrings.pt-BR.xlf | Adds diagnostic translation entry. |
| src/Aspire.Cli/Resources/xlf/SecretCommandStrings.pl.xlf | Adds diagnostic translation entry. |
| src/Aspire.Cli/Resources/xlf/SecretCommandStrings.ko.xlf | Adds diagnostic translation entry. |
| src/Aspire.Cli/Resources/xlf/SecretCommandStrings.ja.xlf | Adds diagnostic translation entry. |
| src/Aspire.Cli/Resources/xlf/SecretCommandStrings.it.xlf | Adds diagnostic translation entry. |
| src/Aspire.Cli/Resources/xlf/SecretCommandStrings.fr.xlf | Adds diagnostic translation entry. |
| src/Aspire.Cli/Resources/xlf/SecretCommandStrings.es.xlf | Adds diagnostic translation entry. |
| src/Aspire.Cli/Resources/xlf/SecretCommandStrings.de.xlf | Adds diagnostic translation entry. |
| src/Aspire.Cli/Resources/xlf/SecretCommandStrings.cs.xlf | Adds diagnostic translation entry. |
| src/Aspire.Cli/Resources/SecretCommandStrings.resx | Defines diagnostic text and translator guidance. |
| src/Aspire.Cli/Resources/SecretCommandStrings.Designer.cs | Exposes the diagnostic resource. |
| src/Aspire.Cli/Commands/SecretPathCommand.cs | Uses path-only resolution. |
| src/Aspire.Cli/Commands/BaseCommand.cs | Handles invalid-secrets errors as command failures. |
| docs/specs/cli-output-formats.md | Documents path lookup and malformed-JSON behavior. |
Review effort: Balanced
Cover a valid canonical store coexisting with malformed legacy secrets and verify failed deletion preserves both files. Co-authored-by: Copilot App <[email protected]>
There was a problem hiding this comment.
🟢 Approval recommended
The narrowly scoped changes have focused regression coverage, address the prior deletion-path feedback, and leave no unresolved blocking findings.
No open issues 🎉
1 resolved since last review
1 file not reviewed
src/Aspire.Cli/Resources/SecretCommandStrings.Designer.cs: Generated file
Review effort: Balanced
This comment has been minimized.
This comment has been minimized.
Co-authored-by: Copilot App <[email protected]>
Tests selector3 / 100 PR test projects · 4 PR jobs, from 21 changed files. Selected PR test projects (3 / 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. |
|
Pull request created: #2051
|
|
📝 Documentation has been drafted in microsoft/aspire.dev#2051 targeting Documented side-effect-free Note This draft PR needs human review before merging. |
…cret path (#2051) Documents changes from microsoft/aspire#21323 Author: ``@IEvangelist`` is the workflow actor; source PR author per the PR metadata. Targeting `release/17.0` based on the source PR milestone `17.0` (exact match). ## Why The source PR makes `aspire secret path` resolve the environment-specific store without parsing/importing/migrating secrets, and reports invalid JSON with file path, line/byte position, and repair guidance. Triggered signals: `cli_command_file_changed` (SecretPathCommand.cs), `cli_resource_strings_changed` (SecretCommandStrings.resx), `pr_body_has_cli_flag_mention`, `pr_body_has_user_facing_section`. ## Changes (updated pages) - `reference/cli/commands/aspire-secret-path.mdx`: notes that the command has no side effects and works with malformed secrets. - `reference/cli/commands/aspire-secret.mdx`: new "Malformed secrets files" section. > Generated by [PR Documentation Check](https://github.com/microsoft/aspire/actions/runs/41870873850) for #21323 · copilot · auto · 25 AIC · ⌖ 1.17 AIC · ⊞ 7.4K · [◷](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: 41870873850, workflow_id: pr-docs-check, run: https://github.com/microsoft/aspire/actions/runs/41870873850 --> <!-- gh-aw-workflow-id: pr-docs-check --> <!-- gh-aw-workflow-call-id: microsoft/aspire/pr-docs-check -->

Description
Malformed secrets JSON currently blocks every
aspire secretoperation, includingsecret path, with an unexpected-error message. Users cannot even locate the environment store to repair it.This change:
secret pathresolve the environment-specific location without parsing, importing, migrating, or initializing secrets. Existing environment filename casing is retained.Reproduction caveat: On Windows x64 with .NET SDK 10.0.403, both CLI
13.4.0+3f0998a95833d5fef96b3159d56b667889b71166and latest stable13.6.4+c89352703f78ae46de90fbf751ed8b52b77b89bfaccept correctly escaped JSON containingserver\\sql. All five commands reproduce the reported error only when the synthetic JSON contains the invalid escapeserver\sql. Both Aspire anddotnet user-secretswriters correctly escape and round-trip the value. This does not establish how the reporter's file reached its failing state, and this PR does not claim to fix valid-backslash corruption.All reproduction used synthetic values and isolated stores. No application was started and no real secrets were read or changed. No new dependencies.
Fixes #21322
User-facing usage
Path lookup still succeeds if secrets are malformed. Data operations instead report a diagnostic like:
The diagnostic names the actual invalid file, including a legacy import or migration source when that is the failing file.
secret pathcontinues to print the canonical Aspire environment-store location, not the legacy import source.Validation
.\restore.cmd— passed; installed repository-pinned SDK11.0.100-rc.2.26504.105.dotnet build src\Aspire.Cli\Aspire.Cli.csproj /t:UpdateXlf --no-restore -v:quiet— passed, 0 warnings/errors.dotnet exec-equivalent invocation ofartifacts\bin\Aspire.Cli\Debug\net11.0\aspire.dll, with isolated malformed legacy secrets — passed:secret pathexits 0 without importing;secret getexits 1 with actionable diagnostics on stderr, empty stdout, unchanged malformed content, and no canonical-store creation.git diff --check— passed.Checklist
<remarks />and<code />elements on your triple slash comments?