Don't throw in CredentialSettings ctor for non-auth clients#56243
Merged
Don't throw in CredentialSettings ctor for non-auth clients#56243
Conversation
Co-authored-by: m-nash <64171366+m-nash@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Fix credential settings ctor to handle null credential section
Don't throw in CredentialSettings ctor for non-auth clients
Feb 13, 2026
JoshLove-msft
approved these changes
Feb 13, 2026
jsquire
approved these changes
Feb 13, 2026
Contributor
There was a problem hiding this comment.
Pull request overview
Adjusts System.ClientModel convenience authentication configuration to allow clients that don’t require auth to initialize even when no credential configuration section is provided.
Changes:
- Updated
CredentialSettings(IConfigurationSection section)to return early whensectionis null (instead of throwing). - Added a unit test covering the null-section constructor scenario.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| sdk/core/System.ClientModel/src/Convenience/CredentialSettings.cs | Allows CredentialSettings construction with a null configuration section by returning early. |
| sdk/core/System.ClientModel/tests/Convenience/CredentialSettingsTests.cs | Adds coverage asserting the ctor does not throw and leaves properties null/default when passed null. |
Member
|
/check-enforcer override |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
The
CredentialSettingsconstructor threwArgumentNullExceptionwhen passed a null section, preventing non-auth clients from initializing without credential configuration.Changes:
CredentialSettingsconstructor to return early whensectionis null instead of throwingBefore:
After:
This checklist is used to make sure that common guidelines for a pull request are followed.
General Guidelines
Testing Guidelines
Original prompt
💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.