Azure / Azure/azure-functions-dotnet-worker

Add converter error information to FunctionInputConverterException

Open
#3,194 1 comment 0 reactions 0 assignees View on GitHub
enhancement
Dominant language
C#
Stars
466
Forks
215
Avg merge
3d 10h
Merged PRs (30d)
7

Description

### Description

### Description

**Feature request**
When creating creating custom `IInputConverters` and returning `ConversionResult.Failed(exception)` the application will throw a `FunctionInputConverterException`, which for `HttpTriggers` will result in a 500 internal server error.
Furthermore this exception has no information aside from the message that a source value could not be parsed to a target type, but the exact items details or not available.

For function applications that deal with `HttpTriggers` it is rather handy to have more information what value was provided and to what type it tried to convert, perhaps even the exception that was supplied with the `ConversionResult.Failed(exception)`.
That way it would be possible to create a middleware that catches the `FunctionInputConverterException` when it concerns a `HttpTrigger` and set the invocation result to a badrequest with problem details thus return a 400 Badrequest.

For non-httptriggers it can be beneficial to create a bit more detailed logs.

**Current workaround**
Currently only a very basic problem details response can be created by attempting to parse the error message and extract the parameter name and type to cast to. One can provide some information but not enrich it, lets say if one used a `ValidationException` to supply insights and a message or so.

Contributor guide

No contributing guide indexed for this repository

Research direction

Start by tracing FunctionInputConverterException from custom IInputConverters that return ConversionResult.Failed(exception), including its handling for HttpTriggers. Done should make the source value, target type, and supplied conversion exception available so middleware and non-HTTP logging can provide richer details.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.