apm-agent-dotnet icon indicating copy to clipboard operation
apm-agent-dotnet copied to clipboard

Avoid NullReferenceException on 401 Unauthorized

Open monty241 opened this issue 8 months ago • 3 comments

We frequently experience NullReferenceExceptions in our logging registered by the first chance exception handler.

It is caused by intakeResponse being not null: Accepted = 0, Errors = null, and then evaluating intakeResponse.Errors.Count triggering an error.

Environment:

Unauthorized 401 on https://53b082e7cfeb4d9a9c117371xxxxxxxx.apm.eu-west-1.aws.cloud.es.io/intake/v2/events

The payload returned is:

{"error":"authentication failed"}\n

So an improvement might be to also deserialize this JSON format.

monty241 avatar Mar 04 '25 11:03 monty241