Bug Description
A NullReferenceException occurs in production when a user visits the details page of a restaurant that has no reviews.
Environment
- Environment: prod
- Date: 2025-12-03
- Time: 12:40:26 CET
- Service: DevEats.Web
Error Details
| Field |
Value |
| Exception Type |
System.NullReferenceException |
| Message |
Object reference not set to an instance of an object |
| Trace ID |
638003fc95071eeb72d35158ec670a07 |
Stack Trace
System.NullReferenceException: Object reference not set to an instance of an object.
at DevEats.Web.Pages.RestaurantDetails.LoadReviews()
in /home/runner/work/deveats/deveats/src/DevEats.Web/Pages/RestaurantDetails.razor:line 959
at DevEats.Web.Pages.RestaurantDetails.LoadData()
in /home/runner/work/deveats/deveats/src/DevEats.Web/Pages/RestaurantDetails.razor:line 945
at DevEats.Web.Pages.RestaurantDetails.OnInitializedAsync()
in /home/runner/work/deveats/deveats/src/DevEats.Web/Pages/RestaurantDetails.razor:line 927
Root Cause
The LoadReviews() method in RestaurantDetails.razor contained deliberate buggy code that was intended for Grafana testing but was deployed to production:
// DELIBERATE BUG FOR GRAFANA TESTING: Null reference when no reviews
if (!reviews.Any())
{
Review? nullReview = null;
var buggyAccess = nullReview.Comment; // This will throw NullReferenceException
}
When a restaurant has no reviews (e.g., Restaurant ID 10), this code attempts to access a property on a null object.
Steps to Reproduce
- Navigate to a restaurant detail page
- Select a restaurant that has no reviews (e.g., restaurant ID 10)
- The page crashes with NullReferenceException
Fix Applied
Removed the deliberate bug code from LoadReviews() method in src/DevEats.Web/Pages/RestaurantDetails.razor.
Bug Description
A
NullReferenceExceptionoccurs in production when a user visits the details page of a restaurant that has no reviews.Environment
Error Details
System.NullReferenceException638003fc95071eeb72d35158ec670a07Stack Trace
Root Cause
The
LoadReviews()method inRestaurantDetails.razorcontained deliberate buggy code that was intended for Grafana testing but was deployed to production:When a restaurant has no reviews (e.g., Restaurant ID 10), this code attempts to access a property on a null object.
Steps to Reproduce
Fix Applied
Removed the deliberate bug code from
LoadReviews()method insrc/DevEats.Web/Pages/RestaurantDetails.razor.