Skip to content

fix NPE with feature reporter not being available - #3199

Merged
Matthew Sainsbury (Microsoft) (mattsains-msft) merged 3 commits into
microsoft:mainfrom
mattsains-msft:feature-reporter-uninitialized
Jul 30, 2026
Merged

Matthew Sainsbury (Microsoft) (mattsains-msft) merged 3 commits into
microsoft:mainfrom
mattsains-msft:feature-reporter-uninitialized

Conversation

@mattsains-msft

Copy link
Copy Markdown
Member

fixes #3197

Changes

FeatureReporter was being called without checking if it is null (for example, when a connection string is not set)

Checklist

  • I ran Unit Tests locally.
  • CHANGELOG.md updated with one line description of the fix, and a link to the original issue if available.

Copilot AI review requested due to automatic review settings July 29, 2026 21:25

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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 addresses crashes when TelemetryConfiguration.FeatureReporter is not initialized (notably when no connection string is configured), by making feature-reporting calls null-safe across TelemetryClient and TelemetryClientExtensions.

Changes:

  • Guard FeatureReporter.MarkFeatureInUse(...) calls with the null-conditional operator (?.) to prevent NullReferenceException.
  • Apply the same null-safety pattern broadly across several TelemetryClient.Track* APIs and StartOperation overloads.
  • Add a changelog entry documenting the fix (with a small wording nit noted in review comments).

Reviewed changes

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

File Description
CHANGELOG.md Documents the fix for #3197 (wording can be tightened).
BASE/src/Microsoft.ApplicationInsights/TelemetryClientExtensions.cs Prevents StartOperation from throwing when FeatureReporter is null.
BASE/src/Microsoft.ApplicationInsights/TelemetryClient.cs Prevents multiple Track* APIs from throwing when FeatureReporter is null.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread CHANGELOG.md
Comment thread BASE/src/Microsoft.ApplicationInsights/TelemetryClientExtensions.cs
@mattsains-msft
Matthew Sainsbury (Microsoft) (mattsains-msft) merged commit f1ab279 into microsoft:main Jul 30, 2026
18 checks passed
@mattsains-msft
Matthew Sainsbury (Microsoft) (mattsains-msft) deleted the feature-reporter-uninitialized branch July 30, 2026 16:38
This was referenced Oct 12, 2026
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.

TelemetryClient.StartOperation crashed due to uninitialized FeatureReporter

4 participants