Azure / Azure/azure-functions-dotnet-worker

Function app should return 405 for request on known route but unsupported HTTP method

Open
#2,452 1 comment 3 reactions 0 assignees View on GitHub
area: http needs-investigation
Dominant language
C#
Stars
466
Forks
215
Avg merge
3d 10h
Merged PRs (30d)
7

Description

I created a C# (isolated) function app with two HTTP-triggered functions. The `/products` path is defined like this:

```csharp
[Function("ProductsEndpoint")]
public async Task Run(
[HttpTrigger(AuthorizationLevel.Function, "get", "post", Route ="products")] HttpRequestData req)
{
```

If I send a DELETE request to this path:
```text
DELETE {{MdkRestServerless_HostAddress}}/api/products
```

the response is a `404 Not Found`:
```text
HTTP/1.1 404 Not Found
Content-Length: 0
Connection: close
Date: Thu, 02 May 2024 00:24:00 GMT
```

but the response _should_ be `405 Method Not Allowed` [[RFC 9110]], since the resource (`/products`) exists but just does not support the `DELETE` method.

[RFC 9110]: https://datatracker.ietf.org/doc/html/rfc9110#section-15.5.6

Contributor guide

No contributing guide indexed for this repository

Research direction

Start at the C# isolated function entry point `ProductsEndpoint.Run` and its `HttpTrigger` declaration for the `/products` route. Trace how a DELETE request is matched when only GET and POST are declared, then exercise the function app with supported and unsupported methods. Done means DELETE on the known route returns 405 instead of 404, while the existing methods continue to work.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp
Domain
api, backend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.