Skip to content

fix the NullReferenceException issue in Azure.ResourceManager.Network #50935

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

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

ArcturusZhang
Copy link
Member

@ArcturusZhang ArcturusZhang commented Jun 27, 2025

Fixes #50934

Since BackendAddressPools property is a collection and does not have a setter, we could not fix the issue that if some one tries to add values directly to this, and gets NRE.

We always recommend to use those properties in the LoadBalancingRuleProperties instead.

Contributing to the Azure SDK

Please see our CONTRIBUTING.md if you are not familiar with contributing to this repository or have questions.

For specific information about pull request etiquette and best practices, see this section.

@Copilot Copilot AI review requested due to automatic review settings June 27, 2025 09:10
@github-actions github-actions bot added the Mgmt This issue is related to a management package. label Jun 27, 2025
Copy link
Contributor

@Copilot 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

This PR fixes a NullReferenceException in LoadBalancingRuleData by ensuring its Properties field is always initialized, and updates the package version and changelog to release the fix.

  • Replaced parameterless LoadBalancingRuleProperties() calls with LoadBalancingRuleProperties(default, default) in each setter
  • Bumped <Version> to 1.11.1 in the project file
  • Added an entry in CHANGELOG.md for the bug fix

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

File Description
sdk/network/Azure.ResourceManager.Network/src/Customization/LoadBalancingRuleData.cs Guard against null Properties by calling the new constructor with defaults
sdk/network/Azure.ResourceManager.Network/src/Azure.ResourceManager.Network.csproj Updated package <Version> to 1.11.1
sdk/network/Azure.ResourceManager.Network/CHANGELOG.md Added release entry and bug fix description
Comments suppressed due to low confidence (2)

sdk/network/Azure.ResourceManager.Network/src/Customization/LoadBalancingRuleData.cs:26

  • Add unit tests to cover the case when Properties is initially null to ensure assignments no longer trigger a NullReferenceException.
                    Properties = new LoadBalancingRuleProperties(default, default);

sdk/network/Azure.ResourceManager.Network/src/Azure.ResourceManager.Network.csproj:3

  • The <Version> was updated to 1.11.1 but the <ApiCompatVersion> remains at 1.11.0. Verify whether the API compatibility version should be aligned with the package version.
    <Version>1.11.1</Version>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Mgmt This issue is related to a management package.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[BUG] Service operations throw NullReferenceException for LoadBalancingRule
2 participants