Skip to content

Feature: Ability to automatically skip null checking for requests DTO in ASP.NET Core #8

@rodion-m

Description

@rodion-m

First of all thank you very much for a great library!
Here is a case:

  1. Create an ASP.NET Core project and add RuntimeNullables package
  2. Create endpoint and request data class:
[Post]
public IActionResult Auth(AuthRequest request)
{
    //logic
}

public record AuthRequest(string Something);
  1. Send a request to this gateway:
{ "Something": null }
  1. Server returned 500 error (cause Something cannot be null), but had to return 400 (Bad Request). So, as you see this is kind of a bug actually.

Of course we can add [NullChecks(false)] attribute to the request class and the bug will disappear, but what if we forget to do that? Again 500? And it's actually not so convenient to add NullChecks to requests explicitly all times.
I suggest to add an ability to automatically skip null checking for requests DTO in ASP.NET Core. Let's discuss an implementation here.

PS. It's interesting that NullGuard.Fody just crashed my app at all when I sent an incorrect request like in the example, but RuntimeNullables only throws an exception and generates 500 (and also customizable). So, I fully migrated from NullGuard.Fody to RuntimeNullables. Thanks again for your work!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions