question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

ProblemDetails: exception details always included regardless of configuration

See original GitHub issue

Hi,

ProblemDetails 6.2.0

In startup.cs I have defined:

            services.AddProblemDetails(options => {
                options.IncludeExceptionDetails = (ctx, ex) => false; //disabled completely for verifying the bug
                options.MapToStatusCode<NotImplementedException>(StatusCodes.Status501NotImplemented);
                    options.MapToStatusCode<HttpRequestException>(StatusCodes.Status503ServiceUnavailable);
                    options.MapToStatusCode<Exception>(StatusCodes.Status500InternalServerError);
                })
                .AddControllers()
                .AddProblemDetailsConventions()
                .AddJsonOptions(x => x.JsonSerializerOptions.IgnoreNullValues = true);

But even with the exception details disabled completely, the inner exception and stack trace are included in the response when performing e.g. a 400 Bad Request .

I can’t seem to find any other conflicting configuration for this in my code.

Any ideas?

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:11 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
khellangcommented, Sep 27, 2021

Lovely. Another reason to stay away from OData 😅

1reaction
spaasiscommented, Sep 27, 2021

D’oh, of course. Now to figure out why the 400 is not mapped correctly with this configuration… Thanks for the assist!

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to use the ProblemDetails middleware in ASP.NET Core
The following configuration will make sure that exception details are included only if you're in the development environment. public void ...
Read more >
Handling Web API Exceptions with ProblemDetails ...
The default configuration converts non-exception responses to ProblemDetails when the following is true: The status code is between 400 and 600 ...
Read more >
Using the ProblemDetails Class in ASP.NET Core Web API
Configuring Exception Details. Firstly, we should always customize the middleware to include the exception details only in the development ...
Read more >
Format response data in ASP.NET Core Web API
Learn how to format response data in ASP.NET Core Web API.
Read more >
Exception Handling in Spring MVC
The most common way to set a default error page has always been the SimpleMappingExceptionResolver (since Spring V1 in fact). We will discuss ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found