Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Null reference exception in WriteJsonImpl #2185

Closed
david-garcia-garcia opened this issue Jan 12, 2024 · 3 comments · Fixed by #2187
Closed

Null reference exception in WriteJsonImpl #2185

david-garcia-garcia opened this issue Jan 12, 2024 · 3 comments · Fixed by #2187
Labels
bug Something isn't working community To tag external issues and PRs good first issue Good for newcomers

Comments

@david-garcia-garcia
Copy link

Description

APM is not reporting, see this from the logs:

System.NullReferenceException: Object reference not set to an instance of an object. at NewRelic.Agent.Core.JsonConverters.LoadedModuleWireModelCollectionJsonConverter.WriteJsonImpl(JsonWriter jsonWriter, LoadedModuleWireModelCollection value) at Newtonsoft.Json.Serialization.JsonSerializerInternalWriter.SerializeConvertable(JsonWriter writer, JsonConverter converter, Object value, JsonContract contract, JsonContainerContract collectionContract, JsonProperty containerProperty) at Newtonsoft.Json.Serialization.JsonSerializerInternalWriter.SerializeList(JsonWriter writer, IEnumerable values, JsonArrayContract contract, JsonProperty member, JsonContainerContract collectionContract, JsonProperty containerProperty) at Newtonsoft.Json.Serialization.JsonSerializerInternalWriter.Serialize(JsonWriter jsonWriter, Object value, Type objectType) at Newtonsoft.Json.JsonSerializer.SerializeInternal(JsonWriter jsonWriter, Object value, Type objectType) at Newtonsoft.Json.JsonConvert.SerializeObjectInternal(Object value, Type type, JsonSerializer jsonSerializer) at NewRelic.Agent.Core.DataTransport.JsonSerializer.Serialize(Object[] parameters) at NewRelic.Agent.Core.DataTransport.ConnectionHandler.SendDataOverWire[T](ICollectorWire wire, String method, Object[] data) at NewRelic.Agent.Core.DataTransport.ConnectionHandler.SendDataRequest[T](String method, Object[] data) at NewRelic.Agent.Core.DataTransport.ConnectionManager.SendDataRequest[T](String method, Object[] data) at NewRelic.Agent.Core.DataTransport.DataTransportService.TrySendDataRequest[T](String method, Object[] data)

This is a log from an IIS hosted APM'ed application.

Expected Behavior

There are no errors, and data ir properly sent to NR APM.

Steps to Reproduce

Not sure.

Your Environment

This is a Windows Server 2022 image running in an AKS cluster. Base image: FROM mcr.microsoft.com/windows/servercore:ltsc2022

Additional context

For Maintainers Only or Hero Triaging this bug

@david-garcia-garcia david-garcia-garcia added the bug Something isn't working label Jan 12, 2024
@workato-integration
Copy link

@github-actions github-actions bot added the community To tag external issues and PRs label Jan 12, 2024
@david-garcia-garcia
Copy link
Author

david-garcia-garcia commented Jan 12, 2024

Unfortunately the dump does not include line numbers, but looking at the implementation:

private static void WriteJsonImpl(JsonWriter jsonWriter, LoadedModuleWireModelCollection value)
        {
            jsonWriter.WriteValue(JarsName);

            jsonWriter.WriteStartArray();

            foreach (var loadedModule in value.LoadedModules)
            {
                // MODULE
                jsonWriter.WriteStartArray();

                jsonWriter.WriteValue(loadedModule.AssemblyName);
                jsonWriter.WriteValue(loadedModule.Version ?? " ");

                // DATA DICTIONARY
                jsonWriter.WriteStartObject();
                foreach (var item in loadedModule.Data)
                {
                    jsonWriter.WritePropertyName(item.Key);
                    jsonWriter.WriteValue(item.Value.ToString());
                }

                jsonWriter.WriteEndObject();

                jsonWriter.WriteEndArray();
            }

            jsonWriter.WriteEndArray();
        }

The method should probably check for null argument, plus the only place i feel could strongly face a NULL reference is "item.Value.ToString()", it should be handled with null propagation.

@tippmar-nr
Copy link
Member

@david-garcia-garcia Thanks for your bug report and assessment of the likely cause. We'll work on fixing this bug soon.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working community To tag external issues and PRs good first issue Good for newcomers
Projects
None yet
2 participants