Repository navigation
Fix guest AppHost secret store resolution - #15220
Conversation
Add `aspire secret path` to show the resolved secrets file path, update guest AppHost user-secrets precedence to honor ASPIRE_USER_SECRETS_ID over the generated server project store, and refresh the related UX text and tests.\n\nCo-authored-by: Copilot <[email protected]>
|
🚀 Dogfood this PR with:
curl -fsSL https://raw.githubusercontent.com/dotnet/aspire/main/eng/scripts/get-aspire-cli-pr.sh | bash -s -- 15220Or
iex "& { $(irm https://raw.githubusercontent.com/dotnet/aspire/main/eng/scripts/get-aspire-cli-pr.ps1) } 15220" |
There was a problem hiding this comment.
Pull request overview
Fixes guest/polyglot AppHost user-secrets resolution/precedence and adds a CLI command to display the resolved secrets file path.
Changes:
- Add
aspire secret pathsubcommand and wire it into DI/command hierarchy. - Update hosting logic to let an explicitly configured
ASPIRE_USER_SECRETS_IDoverride the assemblyUserSecretsIdstore (and remove the previous store source when overriding). - Refresh interaction text and localization entries; add targeted hosting + CLI tests.
Reviewed changes
Copilot reviewed 35 out of 36 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| src/Aspire.Hosting/DistributedApplicationBuilder.cs | Implements new user-secrets precedence and removes overridden secrets configuration sources. |
| tests/Aspire.Hosting.Tests/DistributedApplicationBuilderTests.cs | Adds tests for guest/polyglot secrets path/precedence behavior. |
| src/Aspire.Cli/Commands/SecretPathCommand.cs | Adds secret path command to print resolved secrets file path. |
| src/Aspire.Cli/Commands/SecretCommand.cs | Registers path as a secret subcommand. |
| src/Aspire.Cli/Program.cs | Registers SecretPathCommand in DI. |
| tests/Aspire.Cli.Tests/Utils/CliTestHelper.cs | Registers SecretPathCommand in test DI container. |
| tests/Aspire.Cli.Tests/Commands/SecretCommandTests.cs | Adds CLI tests validating secret path output for .NET and guest AppHosts. |
| src/Aspire.Cli/Resources/SecretCommandStrings.resx | Adds localized description string for secret path. |
| src/Aspire.Cli/Resources/xlf/SecretCommandStrings.*.xlf | Adds XLF entries for the new PathDescription string. |
| src/Aspire.Hosting/Resources/InteractionStrings.resx | Updates interaction text to be AppHost-generic. |
| src/Aspire.Hosting/Resources/xlf/InteractionStrings.*.xlf | Refreshes XLF entries for the updated interaction text. |
Files not reviewed (1)
- src/Aspire.Cli/Resources/SecretCommandStrings.Designer.cs: Language not supported
Comments suppressed due to low confidence (1)
tests/Aspire.Hosting.Tests/DistributedApplicationBuilderTests.cs:1
DeleteUserSecretsFilerecreates the secrets directory after deleting the file. Since this helper is also called fromfinallyblocks, it will leave behind empty per-test directories under the user-secrets root. Consider splitting this into two helpers (e.g., one to ensure the directory exists before writing, and one to delete/cleanup), or add a flag to skip directory creation during cleanup (and optionally delete the directory if empty).
🎬 CLI E2E Test RecordingsThe following terminal recordings are available for commit
📹 Recordings uploaded automatically from CI run #23154876633 |
| return ExitCodeConstants.FailedToFindProject; | ||
| } | ||
|
|
||
| InteractionService.DisplayPlainText(result.Store.FilePath); |
There was a problem hiding this comment.
Does this render as a clickable path in the CLI output?
There was a problem hiding this comment.
I don't think we can even get file paths to be clickable, urls only I think.
|
|
||
| if (filePath is not null && PathsEqual(filePath, userSecretsFilePath)) | ||
| { | ||
| configuration.Sources.RemoveAt(i); |
There was a problem hiding this comment.
Does this remove the full configuration source (for secrets), meaning secrets capabilities all up? We might want to add some sort of note here, as when I first read this code, I was concerned it was removing more than it should.
There was a problem hiding this comment.
Just removing one source. Added a comment right above to clarify the intent.
Co-authored-by: Copilot <[email protected]>
c8916ce
into
release/13.2
Description
Fixes guest/polyglot AppHost user secrets handling on
release/13.2and adds a CLI command to show the resolved secrets file path.aspire secret pathto print the user secrets file used for a given AppHostDistributedApplicationBuilderso an explicitASPIRE_USER_SECRETS_IDfully replaces the generated server project's user-secrets store, while empty values still fall back to the assembly user secrets IDFixes #14788
Validation:
./dotnet.sh test tests/Aspire.Hosting.Tests/Aspire.Hosting.Tests.csproj -v quiet -- --filter-method "*.PolyglotAppHostUsesAspireUserSecretsIdForUserSecretsManager" --filter-method "*.AspireUserSecretsIdOverridesAppHostAssemblyUserSecretsId" --filter-method "*.EmptyAspireUserSecretsIdFallsBackToAppHostAssemblyUserSecretsId" --filter-not-trait "quarantined=true" --filter-not-trait "outerloop=true"./dotnet.sh test tests/Aspire.Cli.Tests/Aspire.Cli.Tests.csproj -v quiet -- --filter-method "*.SecretPath*" --filter-not-trait "quarantined=true" --filter-not-trait "outerloop=true"Checklist
<remarks />and<code />elements on your triple slash comments?aspire.devissue: