Skip to content
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

🐛TypedResults always returning 200 OK with no body #86

Open
michael-wolfenden opened this issue Oct 22, 2024 · 2 comments
Open

🐛TypedResults always returning 200 OK with no body #86

michael-wolfenden opened this issue Oct 22, 2024 · 2 comments
Assignees
Labels
bug Something isn't working

Comments

@michael-wolfenden
Copy link

Given the following code:

async Task Main()
{
  var builder = WebApplication.CreateBuilder();
  builder.Services.AddIdempotentMinimalAPI(new IdempotencyOptions());
  builder.Services.AddIdempotentAPIUsingDistributedCache();
  builder.Services.AddDistributedMemoryCache();

  var app = builder.Build();

  app
    .MapPost("/todoitems/{id}", Results<Ok<Todo>, NotFound>(int id) => TypedResults.Ok(new Todo("My Todo")))
    .AddEndpointFilter<IdempotentAPIEndpointFilter>();

  app.Run();
}

Without the .AddEndpointFilter<IdempotentAPIEndpointFilter>();

POST http://localhost:64913/todoitems/1 HTTP/1.1
User-Agent: vscode-restclient
IdempotencyKey: 9fc0e0e5-a152-468a-beeb-680df8e87bc1
accept-encoding: gzip, deflate

HTTP/1.1 200 OK
Connection: close
Content-Type: application/json; charset=utf-8
Date: Tue, 22 Oct 2024 23:48:58 GMT
Server: Kestrel
Transfer-Encoding: chunked

{
  "name": "My Todo"
}

With the .AddEndpointFilter<IdempotentAPIEndpointFilter>();

POST http://localhost:65077/todoitems/1 HTTP/1.1
User-Agent: vscode-restclient
IdempotencyKey: c79454c9-48e1-498c-8927-7bf8c5f1cf53
accept-encoding: gzip, deflate

HTTP/1.1 200 OK
Connection: close
Content-Type: text/plain; charset=utf-8
Date: Tue, 22 Oct 2024 23:49:49 GMT
Server: Kestrel
Transfer-Encoding: chunked

You also receive a 200 OK if the typed result returns a NotFound

  app
    .MapPost("/todoitems/{id}", Results<Ok<Todo>, NotFound>(int id) => TypedResults.NotFound())
    .AddEndpointFilter<IdempotentAPIEndpointFilter>();
@ikyriak ikyriak self-assigned this Nov 9, 2024
@ikyriak ikyriak added the bug Something isn't working label Nov 9, 2024
@ikyriak
Copy link
Owner

ikyriak commented Nov 9, 2024

Hello @michael-wolfenden,

Thank you for taking the time to report this issue 🙏 .
I will let you know when I have a fix in place.

@ikyriak
Copy link
Owner

ikyriak commented Dec 1, 2024

Hello @michael-wolfenden,

Unfortunately, to support TypedResults will require redesigning the library, including breaking changes. This is an excellent opportunity for me to start it 😄 . However, it will need some time to be completed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants