Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Dec 25, 2025

Description

Since 13.1.0, parameters could not be saved to user secrets because projects lacked a UserSecretsId. This occurred when:

  1. The "Save to user secrets" checkbox was shown even when user secrets weren't configured
  2. The AppHost project was missing a UserSecretsId element

Changes:

  • Added IUserSecretsManager.IsAvailable property - Returns true when UserSecretsId is configured, false otherwise. Implemented in both UserSecretsManager and NoopUserSecretsManager.

  • Updated ParameterProcessor - The "Save to user secrets" checkbox is now always displayed but disabled when userSecretsManager.IsAvailable is false. This provides visual feedback that the feature exists but isn't currently configured, rather than hiding it completely.

  • Added CLI auto-initialization - aspire run now checks AppHost .csproj for UserSecretsId and runs dotnet user-secrets init if missing. Uses XDocument for robust XML parsing. Includes 30-second timeout to prevent hangs.

  • Updated API compatibility suppressions - Added suppressions for the new IsAvailable property and the additional IUserSecretsManager constructor parameter in ParameterProcessor.

Example:

// ParameterProcessor now shows checkbox as disabled when not available
if (showSaveToSecrets)
{
    saveParameters = new InteractionInput
    {
        Name = "RememberParameters",
        InputType = InputType.Boolean,
        Label = InteractionStrings.ParametersInputsRememberLabel,
        Disabled = !userSecretsManager.IsAvailable  // Disabled when not available
    };
    inputs.Add(saveParameters);
}

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 (single boolean property on experimental API)
      • 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
    • No
  • Does the change require an update in our Aspire docs?
    • Yes
    • No
Original prompt

This section details on the original issue you should resolve

<issue_title>User secret for Params are not saved since 13.1.0</issue_title>
<issue_description>### Is there an existing issue for this?

  • I have searched the existing issues

Describe the bug

When use 13.1.0 my parameters ended up in another tab, but when press save to user secret it does not do that any more

Expected Behavior

When press save in user secret it saves in user secret as before

Steps To Reproduce

Add parameters
Add 13.1.0 SDK

run with parameters, edit and check the user secret save checkbox

Exceptions (if any)

No response

.NET Version info

No response

Anything else?

No response</issue_description>

<agent_instructions>We want to make a couple of changs here:

  • The aspire CLI should add run dotnet user secrets init if there's no user secrets id. This will ensure that projects have or get user secrets if there isn't any.
  • We should disable the save to user secrets in the dialog if there's no user secrets id, we should base it on IUserSecretsManager.IsAvailable (add a property). This input should be visible but disabled to let the user know its not property set up
    if (showSaveToSecrets)
    {
    saveParameters = new InteractionInput
    {
    Name = "RememberParameters",
    InputType = InputType.Boolean,
    Label = InteractionStrings.ParametersInputsRememberLabel
    };
    inputs.Add(saveParameters);
    }
    .
    </agent_instructions>

Comments on the Issue (you are @copilot in this section)

@davidfowl Just tried a new project on 13.1 works like a charm. Can you provide more details? Does your project have a user secrets id? @davidfowl You're missing the user secrets id (which comes with the apphost template), run `dotnet user-secrets init` in that folder with the apphost and it'll add an id in there. @davidfowl No it's not automatically added. Saving should never work without it. We don't do enough to warn you that this is the case though. We should update the UI to disable the button if there's no user secrets id.

cc @JamesNK since you are touching this area</comment_new>


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Copilot AI and others added 3 commits December 25, 2025 00:51
…crets initialization in CLI

Co-authored-by: davidfowl <95136+davidfowl@users.noreply.github.com>
…UserSecretsManager

Co-authored-by: davidfowl <95136+davidfowl@users.noreply.github.com>
…imeout to process execution

Co-authored-by: davidfowl <95136+davidfowl@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix user secret saving issue in SDK 13.1.0 Fix user secrets saving for parameters - add IsAvailable property and CLI auto-initialization Dec 25, 2025
Copilot AI requested a review from davidfowl December 25, 2025 01:10
InteractionInput? saveParameters = null;

if (showSaveToSecrets)
if (showSaveToSecrets && userSecretsManager.IsAvailable)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot We don't want to skip the input, we want to disable it.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in e08d8d1. The "Save to user secrets" checkbox is now always shown but disabled when user secrets are not available, allowing users to see the option exists even when it's not configured.

… when user secrets not available

Co-authored-by: davidfowl <95136+davidfowl@users.noreply.github.com>
@davidfowl
Copy link
Member

@copilot Run dotnet pack /p:ApiCompatGenerateSuppressionFile=true on Aspire.Hosting to update the supressions file

Co-authored-by: davidfowl <95136+davidfowl@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Dec 25, 2025

@copilot Run dotnet pack /p:ApiCompatGenerateSuppressionFile=true on Aspire.Hosting to update the supressions file

Done in 028021c. The API compatibility suppressions file has been updated to account for the new IUserSecretsManager.IsAvailable property and the additional constructor parameter in ParameterProcessor.

@github-actions
Copy link
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/dotnet/aspire/main/eng/scripts/get-aspire-cli-pr.sh | bash -s -- 13702

Or

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

@davidfowl davidfowl requested a review from JamesNK December 25, 2025 06:44
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.

User secret for Params are not saved since 13.1.0

2 participants