-
Notifications
You must be signed in to change notification settings - Fork 10.5k
Closed
Labels
DoneThis issue has been fixedThis issue has been fixedarea-mvcIncludes: MVC, Actions and Controllers, Localization, CORS, most templatesIncludes: MVC, Actions and Controllers, Localization, CORS, most templateshelp wantedUp for grabs. We would accept a PR to help resolve this issueUp for grabs. We would accept a PR to help resolve this issuetask
Milestone
Description
Describe the bug
During Unit Tests, I was getting a NullReferenceExeption in ControllerBase.ValidationProblem. Difficult to narrow down the problem.
To Reproduce
Steps to reproduce the behavior:
- 3.0.0
- Create a controller unit test of an action that calls ValidationResult.
var c = new MyController();
c.MyAction(); // Should call return new ValidationResult;
- NullReferenceException was due to
ProblemDetailsFactorybeing null, asProblemDetailsFactory => HttpContext?.RequestServices?.GetRequiredService<ProblemDetailsFactory>()silently returns null.
Expected behavior
Error message should be actual problem. NullReferenceException is not clear. Perhaps check for null when returning ProblemDetailsFactory property.
Additional context
Add any other context about the problem here.
Include the output of dotnet --info
Metadata
Metadata
Assignees
Labels
DoneThis issue has been fixedThis issue has been fixedarea-mvcIncludes: MVC, Actions and Controllers, Localization, CORS, most templatesIncludes: MVC, Actions and Controllers, Localization, CORS, most templateshelp wantedUp for grabs. We would accept a PR to help resolve this issueUp for grabs. We would accept a PR to help resolve this issuetask