Skip to content
This repository has been archived by the owner on Dec 8, 2018. It is now read-only.

ArgumentNullException when not setting Name in IHealthCheck #519

Closed
andrecarlucci opened this issue Oct 29, 2018 · 2 comments
Closed

ArgumentNullException when not setting Name in IHealthCheck #519

andrecarlucci opened this issue Oct 29, 2018 · 2 comments
Labels

Comments

@andrecarlucci
Copy link

Hi guys,

You will get an ArgumentNullException when creating your own HealthCheck handler without setting something to its Name property:

Microsoft.AspNetCore.Server.Kestrel:Error: Connection id "0HLHTL2OE18LU", Request id "0HLHTL2OE18LU:00000002": An unhandled exception was thrown by the application.

System.ArgumentNullException: Value cannot be null.
Parameter name: key
   at System.Collections.Generic.Dictionary`2.TryInsert(TKey key, TValue value, InsertionBehavior behavior)
   at System.Collections.Generic.Dictionary`2.set_Item(TKey key, TValue value)
   at Microsoft.Extensions.Diagnostics.HealthChecks.HealthCheckService.CheckHealthAsync(Func`2 predicate, CancellationToken cancellationToken)
   at Microsoft.AspNetCore.Diagnostics.HealthChecks.HealthCheckMiddleware.InvokeAsync(HttpContext httpContext)
   at Microsoft.AspNetCore.Builder.Extensions.MapMiddleware.Invoke(HttpContext context)
   at Microsoft.AspNetCore.Server.IISIntegration.IISMiddleware.Invoke(HttpContext httpContext)
   at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http.HttpProtocol.ProcessRequests[TContext](IHttpApplication`1 application)

As the exception is not helpful at all, it took me a little while to figure it out (I had to look at the source code).

I believe the solution for this would be:

  • A specific exception for this
    or
  • The default name is the class full name or whatever

Thanks!

@mkArtakMSFT
Copy link
Member

Thanks for contacting us, @andrecarlucci.
@rynowak, seems like something we can do in 2.2 timeframe.

@mkArtakMSFT mkArtakMSFT added bug 1 - Ready PRI: 2 - Preferred Preferably should be handled during the milestone. labels Oct 29, 2018
@mkArtakMSFT mkArtakMSFT added this to the 2.2.0 milestone Oct 29, 2018
@rynowak
Copy link
Member

rynowak commented Oct 29, 2018

Hi, @andrecarlucci - as of 2.2.0-preview3 the health check doesn't define its own name, it's passed in (and null-checked) when the check is registered.

@rynowak rynowak closed this as completed Oct 29, 2018
@rynowak rynowak added invalid and removed 1 - Ready PRI: 2 - Preferred Preferably should be handled during the milestone. bug labels Oct 29, 2018
@rynowak rynowak removed this from the 2.2.0 milestone Oct 29, 2018
@rynowak rynowak removed their assignment Oct 29, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

3 participants