- 
                Notifications
    You must be signed in to change notification settings 
- Fork 715
Fix parameter substitution in GitHub Models #10428
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR ensures that when WithApiKey is called multiple times, only the initially generated default parameter is removed, and subsequent custom parameters remain intact.
- Update WithApiKeyremoval logic to target only the default key parameter.
- Add a new unit test to verify the behavior when calling WithApiKeytwice.
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description | 
|---|---|
| tests/Aspire.Hosting.GitHub.Models.Tests/GitHubModelsExtensionTests.cs | Added WithApiKeyCalledTwiceOnlyRemovesDefaultParametertest to confirm only the default key is removed on the first call. | 
| src/Aspire.Hosting.GitHub.Models/GitHubModelsExtensions.cs | Modified WithApiKeyto remove the existing API key only if it matches the default parameter name. | 
Comments suppressed due to low confidence (1)
tests/Aspire.Hosting.GitHub.Models.Tests/GitHubModelsExtensionTests.cs:271
- Add an assertion to verify that builder.Resource.Key.Nameis updated to the new API key parameter (e.g., "secret-key2") after each call toWithApiKey, ensuring that the resource builder reflects the latest key.
        github.WithApiKey(builder.AddParameter("secret-key2", secret: true));
* Fix parameter substitution in GitHub Models * Use reference
* Simplify GH Models API keys experience * Fix parameter substitution in GitHub Models (#10428) * Fix parameter substitution in GitHub Models * Use reference --------- Co-authored-by: Sebastien Ros <sebastienros@gmail.com>
Description
When calling the method twice the parameter may be removed by mistake.
Fixes #10424 (review)
Checklist
<remarks />and<code />elements on your triple slash comments?