-
Notifications
You must be signed in to change notification settings - Fork 10.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
RequestDelegateFactory should produce clear errors for invalid Delegates #30322
Comments
Thanks for contacting us. |
This might be done, all bullets either have a linked issue/PR that is closed or are marked "nothing to do". |
Lets verify first before closing |
All 7 scenarios validated against RTM build and before/after for each shown below. Scenario 1:
Before: After:
Scenario 2:
Scenario 3:
Scenario 4Part 1:
Part 2:
Before:
After:
Part 2: On Request
Scenario 5Improve the error message when routes parameters do not match or just ignore casing(lower/upper)
Before: After: Scenario 6What should we do when someone uses attributes that should not be allowed on certain methods?
Before: After: Scenario 7Adding an optional/nullability (?) in the route pattern, messes up the Swagger UI and the json file still recognizes as required field. |
Is your feature request related to a problem? Please describe.
We should make sure its clear what is supported in MapAction instead of it failing with hard to grok errors. For example, #31658 (comment)
Describe the solution you'd like
I think we should have both runtime and compile time validation (an analyzer where possible).
Scenarios for MapActions
1. Forgetting to register a service with the DI container generates an incorrect error as the parameter is viewed as second [FromBody] attribute. Although from the user standpoint the second [FromBody] attribute is not explicit - #35086
The user's intention was to inject the UserRepository as service to use.
Error message:
2. Allowing query strings on Post is not semantically correct and might be viewed as a security issue. The user would have expected the [FromQuery] attribute to be ignored/should not bind or should throw an exception at the startup time. Nothing to do.
3. FromBody attribute on MapGet does not throw an exception. (User could have copied the method and forget to remove the frombody). Postman allows you to add a body to a get method. However, without a body added to the request, we get 400 which is the correct behavior. If the body is present, binding happens. - Nothing to do - this is by design
4. In MapGet an implicit injection of any service returns a 400 if the user forgot to register the service in the DI container. However, an explicit use of [FromServices] returns the correct error. This is inconsistent - #35086
Error for explicit use of [FromServices]
5. Improve the error message when routes parameters do match or just ignore casing(lower/upper) - This is a common mistake that users may make - #35087
Error message (Notice FirstName != firstName):
6. What should we do when someone uses attributes that should not be allowed on certain methods ? see example below: -#35088
7. Adding an optional/nullability (?) in the route pattern, messes up the Swagger UI and the json file still recognizes as required field. - #35081
Notice the missing closing bracket
![image](https://user-images.githubusercontent.com/87031580/128391751-8a8f59de-9ebc-4233-b47f-755e4f32fc5e.png)
The text was updated successfully, but these errors were encountered: