Farfetch / loadshedding

A .NET library created to assist the applications in applying LoadShedding techniques and making it easy to configure it
https://farfetch.github.io/loadshedding/
MIT License
85 stars 10 forks source link

[Bug Report]: Load Shedding hides errors #20

Closed hades200082 closed 4 months ago

hades200082 commented 5 months ago

Prerequisites

Description

I have a .Net 8 WebAPI that I've been building out and I added LoadShedding to it today.

I've noticed now that any time an exception would be thrown, returning a 500 error to the client it instead returns an empty 200 response instead.

Steps to reproduce

  1. Create a basic .Net 8 WebAPI (Controllers) application
  2. Create a controller as below.
  3. Add load shedding with defaults
  4. Run the application and use a tool like Postman to hit the endpoint
[ApiController]
[Route("[controller]")]
public sealed class EchoController : ControllerBase
{
    [HttpGet("test/error")]
    public async Task<IActionResult> TestError(CancellationToken cancellationToken = default)
    {
        throw new Exception("Something went wrong");
    }
}

The same issue happens for Unauthorized responses:

    [HttpGet("test/auth")]
    [Authorize]
    public async Task<IActionResult> TestAuth(CancellationToken cancellationToken = default)
    {
        return Ok("Authorized");
    }

If you hit this endpoint while not authenticated you also get a blank 200 response.

Expected behavior

I'd expect error responses to be preserved so that client applications can respond correctly.

Actual behavior

A blank 200 response is returned for errors.

LoadShedding version

1.0.0

ailtonguitar commented 5 months ago

Hi @hades200082 ! Thanks for reporting the issue, we'll investigate and give you a feedback.

hades200082 commented 4 months ago

Has there been any progress tracking this down? It's the only thing stopping me really using LoadShedding right now.

ailtonguitar commented 4 months ago

Has there been any progress tracking this down? It's the only thing stopping me really using LoadShedding right now.

Hi @hades200082! I've created a PR with the fix https://github.com/Farfetch/loadshedding/pull/24

hades200082 commented 4 months ago

Has there been any progress tracking this down? It's the only thing stopping me really using LoadShedding right now.

Hi @hades200082! I've created a PR with the fix #24

Awesome news! I'll give it a try