Azure / Azure/azure-functions-dotnet-worker
HTTP status code differs between NoContentResult and ContentResult when Queue Output Binding fails
- Dominant language
- C#
- Stars
- 466
- Forks
- 215
- Avg merge
- 3d 10h
- Merged PRs (30d)
- 7
Description
### Description
When using Azure Functions with both HTTP output and Queue output bindings, the queue binding failure behavior differs based on the type of `IActionResult` returned. I would expect the HTTP status code to be 500 when writing to the queue fails (due to `Connection` set to *broken-connection-str*).
In the included `TestFunctions` i get the following results:
* TestFail endpoint (/test/f) using NoContentResult - Returns HTTP 500 👍
* TestSuccess endpoint (/test/s) using ContentResult - Returns HTTP 200 👎
### Steps to reproduce
```cs
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Azure.Functions.Worker;
using Microsoft.Extensions.Logging;
namespace MyProject;
public class TestFunctions
{
private readonly ILogger _logger;
public TestFunctions(ILogger logger)
{
_logger = logger;
}
// Returns HTTP status code 500
[Function("TestFail")]
public TestFunctionOutput RunFail(
[HttpTrigger(AuthorizationLevel.Anonymous, "get", "post", Route = "test/f")]
HttpRequest req)
{
return new TestFunctionOutput
{
Result = new NoContentResult(),
QueueOutput = "Text for the queue"
};
}
// Returns HTTP status code 200
[Function("TestSuccess")]
public TestFunctionOutput RunSuccess(
[HttpTrigger(AuthorizationLevel.Anonymous, "get", "post", Route = "test/s")]
HttpRequest req)
{
return new TestFunctionOutput
{
Result = new ContentResult
{
Content = "world", ContentType = "application/xml"
},
QueueOutput = "Text for the queue"
};
}
public class TestFunctionOutput
{
[HttpResult]
public IActionResult Result { get; init; }
[QueueOutput("some-queue", Connection = "broken-connection-str")]
public string QueueOutput { get; init; }
}
}
```
Contributor guide
No contributing guide indexed for this repository
Research direction
Start with the included TestFunctions reproduction and run both /test/f and /test/s with the broken queue connection. Compare how NoContentResult and ContentResult handle the queue binding failure; done means both endpoints return the expected HTTP 500 response when queue output fails.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- azure, csharp
- Domain
- api, backend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 55/100