Skip to content

Don't throw in CredentialSettings ctor for non-auth clients#56243

Merged
m-nash merged 2 commits intomainfrom
copilot/fix-credential-settings-ctor
Feb 13, 2026
Merged

Don't throw in CredentialSettings ctor for non-auth clients#56243
m-nash merged 2 commits intomainfrom
copilot/fix-credential-settings-ctor

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Feb 13, 2026

Description

The CredentialSettings constructor threw ArgumentNullException when passed a null section, preventing non-auth clients from initializing without credential configuration.

Changes:

  • Modified CredentialSettings constructor to return early when section is null instead of throwing
  • Added test coverage for null section handling

Before:

public CredentialSettings(IConfigurationSection section)
{
    if (section is null)
    {
        throw new ArgumentNullException(nameof(section));
    }
    // ...
}

After:

public CredentialSettings(IConfigurationSection section)
{
    if (section is null)
    {
        return;  // Properties remain null, suitable for non-auth clients
    }
    // ...
}

This checklist is used to make sure that common guidelines for a pull request are followed.

General Guidelines

  • Title of the pull request is clear and informative.
  • There are a small number of commits, each of which have an informative message. This means that previously merged commits do not appear in the history of the PR. For more information on cleaning up the commits in your PR, see this page.

Testing Guidelines

  • Pull request includes test coverage for the included changes.
Original prompt

This section details on the original issue you should resolve

<issue_title>Don't throw in credential settings ctor for non auth clients</issue_title>
<issue_description>https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/core/System.ClientModel/src/Convenience/CredentialSettings.cs#L23

Just return when the credential section is null</issue_description>

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


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

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
Copilot AI requested a review from m-nash February 13, 2026 01:10
@m-nash m-nash marked this pull request as ready for review February 13, 2026 01:23
@m-nash m-nash requested a review from a team as a code owner February 13, 2026 01:23
Copilot AI review requested due to automatic review settings February 13, 2026 01:23
@m-nash m-nash enabled auto-merge (squash) February 13, 2026 01:24
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

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 when section is 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.

@m-nash
Copy link
Copy Markdown
Member

m-nash commented Feb 13, 2026

/check-enforcer override

@m-nash m-nash merged commit 30a5b6e into main Feb 13, 2026
51 of 52 checks passed
@m-nash m-nash deleted the copilot/fix-credential-settings-ctor branch February 13, 2026 02:07
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.

Don't throw in credential settings ctor for non auth clients

5 participants