Skip to content

EDM model exception of OData not caught in global exception handler  #2616

@gohilravi

Description

@gohilravi

Short summary (3-5 sentences) describing the issue.
When providing the wrong input parameter in the OData function i.e. string instead of integer then ODataException is thrown which is not caught in the global exception handler and below error is returned:
Microsoft.OData.ODataException: The parameter value ($234) from request is not valid. The parameter value should be format of type 'Edm.Int64'. ---> Microsoft.OData.ODataException: Expected literal type token but found token '$234'. at Microsoft.OData.UriParser.ExpressionLexerLiteralExtensions.ReadLiteralToken(ExpressionLexer expressionLexer) at Microsoft.OData.ODataUriUtils.ConvertFromUriLiteral(String value, ODataVersion version, IEdmModel model, IEdmTypeReference typeReference) at Microsoft.AspNetCore.OData.Routing.Template.SegmentTemplateHelpers.Match(ODataTemplateTranslateContext context, IEdmFunction function, IDictionary'2 parameterMappings) --- End of inner exception stack trace --- at Microsoft.AspNetCore.OData.Routing.Template.SegmentTemplateHelpers.Match(ODataTemplateTranslateContext context, IEdmFunction function, IDictionary' parameterMappings) at Microsoft.AspNetCore.OData.Routing.Template.FunctionSegmentTemplate.TryTranslate(ODataTemplateTranslateContext context) at Microsoft.AspNetCore.OData.Routing.Template.DefaultODataTemplateTranslator.Translate(ODataPathTemplate path, ODataTemplateTranslateContext context) at Microsoft.AspNetCore.OData.Routing.ODataRoutingMatcherPolicy.ApplyAsync(HttpContext httpContext, CandidateSet candidates) at Microsoft.AspNetCore.Routing.Matching.DfaMatcher.SelectEndpointWithPoliciesAsync(HttpContext httpContext, IEndpointSelectorPolicy[] policies, CandidateSet candidateSet) at Microsoft.AspNetCore.Routing.EndpointRoutingMiddleware.<Invoke>g__AwaitMatch|8_1(EndpointRoutingMiddleware middleware, HttpContext httpContext, Task matchTask) at Serilog.AspNetCore.RequestLoggingMiddleware.Invoke(HttpContext httpContext) at CorrelationId.CorrelationIdMiddleware.Invoke(HttpContext context, ICorrelationContextFactory correlationContextFactory) at Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddleware.Invoke(HttpContext context)

Assemblies affected

Microsoft.OData 8.0.6 NuGet package

Reproduce steps

Attached screenshot of the issue.
OData exception

Expected result

The exception should be handled in the global exception handler.

Actual result

The exception is not being handled in the global exception handler.

Additional detail

  • When providing an invalid value like providing $234 instead of long value 234 in the request parameter id then OData exception is thrown which is not caught in the global exception handler.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions