Open
Description
Background
In PR #208 (feature/identifiers), several columns in the Player entity were changed from non-nullable to nullable:
- FirstName
- LastName
- Position
- AbbrPosition
- DateOfBirth
Issues Identified
The code review identified potential null handling concerns:
-
The validator () enforces non-null/empty values for FirstName, LastName, and AbbrPosition, but there's no corresponding check for DateOfBirth or Position.
-
In the mapping profile (), the DateOfBirth property is formatted directly using string interpolation (
$"{source.DateOfBirth:MMMM d, yyyy}"
), which can throw an exception if DateOfBirth is null. -
While test files currently provide values for these columns, null scenarios may occur in production.
Recommended Actions
- DateOfBirth: Update the mapping to safely handle null values (e.g., use a conditional to supply a default string or check for HasValue) or enforce non-null validation if a value is required.
- Position: Confirm that the intended behavior for nullable Position is correctly managed in both validation and mapping scenarios.
References
- PR: feature/identifiers #208
- Discussion: feature/identifiers #208 (comment)