Problem
ValidateController.ProcessResource() at line 74 has the same null-dereference pattern as #5114 (ParameterCompatibleFilter.ParseResource()):
resource = parameterResource.Parameter.Find(param => param.Name.Equals("resource", StringComparison.OrdinalIgnoreCase)).Resource;
If .Find() returns null (no "resource" parameter exists), accessing .Resource throws NullReferenceException.
Additionally, line 60 does not null-check parameterResource.Parameter:
var profileFromParameters = parameterResource.Parameter.Find(param => ...);
Root Cause
No null-safety on the result of .Find() or on the Parameter collection itself. The Copilot PR #5115 fixes this in ParameterCompatibleFilter.cs but the same pattern exists in ValidateController.ProcessResource().
Proposed Fix
Add null-safety checks matching the pattern from PR #5115:
- Null-check
parameterResource.Parameter before calling .Find()
- Null-check the
.Find() result before accessing .Resource
Affected File
src/Microsoft.Health.Fhir.Shared.Api/Controllers/ValidateController.cs lines 60, 74
Problem
ValidateController.ProcessResource()at line 74 has the same null-dereference pattern as #5114 (ParameterCompatibleFilter.ParseResource()):If
.Find()returnsnull(no "resource" parameter exists), accessing.ResourcethrowsNullReferenceException.Additionally, line 60 does not null-check
parameterResource.Parameter:Root Cause
No null-safety on the result of
.Find()or on theParametercollection itself. The Copilot PR #5115 fixes this inParameterCompatibleFilter.csbut the same pattern exists inValidateController.ProcessResource().Proposed Fix
Add null-safety checks matching the pattern from PR #5115:
parameterResource.Parameterbefore calling.Find().Find()result before accessing.ResourceAffected File
src/Microsoft.Health.Fhir.Shared.Api/Controllers/ValidateController.cslines 60, 74