CVE-2026-71262: Csharp Linq First Followed By Null Check

Calling .First() throws an InvalidOperationException when no item is found, making subsequent null checks unreachable and causing unhandled exceptions. Use .FirstOrDefault() instead.

Provally CuratedPublic repositoryMediumMedium confidenceVerifiedApache-2.0C#
greprules fetch cve-2026-71262-csharp-linq-first-followed-by-null-check --engine opengrep

Description

Calling .First() throws an InvalidOperationException when no item is found, making subsequent null checks unreachable and causing unhandled exceptions. Use .FirstOrDefault() instead.