add null-safety checks in ValidateController.ProcessResource()#5671
Open
v-rachitsh wants to merge 4 commits into
Open
add null-safety checks in ValidateController.ProcessResource()#5671v-rachitsh wants to merge 4 commits into
v-rachitsh wants to merge 4 commits into
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #5671 +/- ##
==========================================
+ Coverage 77.51% 77.54% +0.03%
==========================================
Files 1005 1005
Lines 36943 36946 +3
Branches 5601 5603 +2
==========================================
+ Hits 28635 28649 +14
+ Misses 6948 6936 -12
- Partials 1360 1361 +1 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #5627
Related issues
AB#198060
Summary
Adds null-safety checks in
ValidateController.ProcessResource()to preventNullReferenceExceptionwhen a Parameters resource is missing the expected "resource" parameter or has a null Parameter collection.This is the same class of bug fixed in PR #5115 for
ParameterCompatibleFilter.ParseResource(), but in a separate code path.Root Cause
ProcessResource()at line 74 called.Find(...).Resourcewithout null-checking the result of.Find(). If no parameter named "resource" exists,.Find()returnsnulland accessing.ResourcethrowsNullReferenceException.Additionally,
parameterResource.Parameterwas accessed without null-checking, which would also throw if the Parameter collection itself is null.Changes
ValidateController.cs?.null-conditional operator onresource.TypeNamecheck?.null-conditional operator onparameterResource.Parameteraccess.Find(...).Resourcechain into separate null-safe steps matching the pattern from PR Fix NullReferenceException in ParameterCompatibleFilter.ParseResource() during resource validation #5115ValidateControllerTests.csGivenParametersWithNullParameterCollection_WhenValidating_ThenShouldNotThrowNullReferenceExceptionGivenParametersWithMissingResourceParameter_WhenValidating_ThenShouldNotThrowNullReferenceExceptionGivenParametersWithNullResourceParameter_WhenValidating_ThenShouldNotThrowNullReferenceExceptionVerification
Structural verification: the fix follows the exact same null-safety pattern established in PR #5115 for
ParameterCompatibleFilter.cs. Each.Find()result is now checked for null before accessing.Resource.Files Changed
Verification