Skip to content

[BUG] FillApmServerInfo : Invalid ElasticApm_ApiKey throws object not set exception #1735

@stephdep

Description

@stephdep

APM Agent version

Latest Main branch code on 16/6/2022

Environment

Operating system and version:

.NET Framework/Core name and version (e.g. .NET 4.6.1, NET Core 3.1.100) :
.Net 6

Application Target Framework(s) (e.g. net461, netcoreapp3.1):
.Net 6

Describe the bug

When connecting using an ElasticApm_ApiKey that is invalid, an exception is thrown when calling app.UseAllElasticApm(Configuration);

reason is that the Elastic.Apm.ServerInfo.ApmServerInfoProvider FillApmServerInfo does a request that succeeds, but does not return any data, and therefore the deSerialisation returns metadata null, then doing metadata["version"] throws an "object not set to an instance of an object" exception.

				var metadata = serializer.Deserialize<JObject>(jsonReader);
				**var version = metadata["version"];**

To Reproduce

Steps to reproduce the behavior:
Configure an invalid Api Key in ElasticApm_ApiKey
use the app.UseAllElasticApm(Configuration); as explained for .Net core.
an exception is thrown

Expected behavior

improve the code :

  • include the Deserialize in the foreseen try catch
  • what if strVersion is null, no callbackInFinish is called

Actual behavior

throws Object not set to an instance of an object exception

Metadata

Metadata

Assignees

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions