-
Notifications
You must be signed in to change notification settings - Fork 178
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
Exception handling middleware fails for void return type #1619
Comments
Notes from investigation:
In both cases ( The function metadata generated for the 2 functions are as below. note that the "throw-exception" function is missing the public Task<ImmutableArray<IFunctionMetadata>> GetFunctionMetadataAsync(string directory)
{
var metadataList = new List<IFunctionMetadata>();
var Function0RawBindings = new List<string>();
Function0RawBindings.Add(@"{""name"":""req"",""type"":""httpTrigger"",""direction"":""In"",""authLevel"":""Anonymous"",""methods"":[""get""],""route"":""throw-exception""}");
var Function0 = new DefaultFunctionMetadata
{
Language = "dotnet-isolated",
Name = "ThrowException",
EntryPoint = "MiddlewareStatusCode.ExceptionController.ThrowException",
RawBindings = Function0RawBindings,
ScriptFile = "MiddlewareStatusCode.dll"
};
metadataList.Add(Function0);
var Function1RawBindings = new List<string>();
Function1RawBindings.Add(@"{""name"":""req"",""type"":""httpTrigger"",""direction"":""In"",""authLevel"":""Anonymous"",""methods"":[""get""],""route"":""throw-exception-and-return/{returnUsefullData}""}");
Function1RawBindings.Add(@"{""name"":""$return"",""type"":""http"",""direction"":""Out""}");
var Function1 = new DefaultFunctionMetadata
{
Language = "dotnet-isolated",
Name = "ThrowExceptionAndReturn",
EntryPoint = "MiddlewareStatusCode.ExceptionController.ThrowExceptionAndReturn",
RawBindings = Function1RawBindings,
ScriptFile = "MiddlewareStatusCode.dll"
};
metadataList.Add(Function1);
return Task.FromResult(metadataList.ToImmutableArray());
} The For the "throw-exception-and-return" function, there is one output binding which causes the HttpBinding.BindAsync method to be invoked. For Next step is to discuss how /where to handle this.Option1Update metadata generation to create the Option2Update host code to use a fallback |
Discussed this in triage. We'll move forward with option 1 and keep this issue open to track the work. |
Version 1.17.4 of Worker.Sdk includes the fix for the issue. Please upgrade your package to this version, and feel free to reach out if you encounter any further issues. |
See #936, which was closed despite not being fixed.
If you use the sample exception handling middleware and have an http triggered functions with
void
or bareTask
return type that throws an exception the request results in a 200 response and the whole http response is returned as json.I have created a minimal example which shows the error, as well as showing how returning a different return type works fine.
i.e. the request to the
void
function returns the wrong status code and responsewhereas the endpoint that has a non-void return type gives the correct 500 response
I have tried fiddling with the middleware to get this working, but there doesn't seem to be a way. So I think this is a bug in the underlying framework. There doesn't seem to be any reason I shouldn't be able to have a request with a
void
return type.The text was updated successfully, but these errors were encountered: