Skip to content

Fix NRE in CohostDocumentPullDiagnosticsEndpointBase.GetDiagnosticsAsync#13044

Merged
ToddGrun merged 1 commit intomainfrom
dev/toddgrun/2601367
Apr 13, 2026
Merged

Fix NRE in CohostDocumentPullDiagnosticsEndpointBase.GetDiagnosticsAsync#13044
ToddGrun merged 1 commit intomainfrom
dev/toddgrun/2601367

Conversation

@ToddGrun
Copy link
Copy Markdown

When the remote service call fails, TryInvokeAsync catches the exception and returns default. For ImmutableArray, default has a null internal array, so accessing .Length throws NullReferenceException. The existing guard only checked cancellationToken.IsCancellationRequested, which handles the cancellation path but not the error path.

Add a diagnostics.IsDefault check to return null when the remote call fails, matching the existing cancellation behavior.

Fixes https://devdiv.visualstudio.com/DevDiv/_workitems/edit/2601367 -- (111K hits across 18.0-18.7).

When the remote service call fails, TryInvokeAsync catches the exception and returns default. For ImmutableArray<T>, default has a null internal array, so accessing .Length throws NullReferenceException. The existing guard only checked cancellationToken.IsCancellationRequested, which handles the cancellation path but not the error path.

 Add a diagnostics.IsDefault check to return null when the remote call fails, matching the existing cancellation behavior.

 Fixes https://devdiv.visualstudio.com/DevDiv/_workitems/edit/2601367 -- (111K hits across 18.0-18.7).
@ToddGrun ToddGrun requested a review from a team as a code owner April 13, 2026 18:46
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.

3 participants