Skip to content

AuditThroughputCollectorHostedService can throw a null reference exception #4846

@andreasohlund

Description

@andreasohlund

Describe the bug

Description

Spotted this in a customer logfile

2025-02-20 12:28:42.5872|30|Error|Particular.LicensingComponent.AuditThroughput.AuditThroughputCollectorHostedService|Failed to gather throughput from audit|System.NullReferenceException: Object reference not set to an instance of an object.
   at System.Linq.Enumerable.SelectManySingleSelectorIterator`2.MoveNext()
   at System.Linq.Lookup`2.Create(IEnumerable`1 source, Func`2 keySelector, IEqualityComparer`1 comparer)
   at System.Linq.GroupedEnumerable`2.GetEnumerator()
   at System.Linq.Enumerable.SelectEnumerableIterator`2.ToArray()
   at System.Linq.Buffer`1..ctor(IEnumerable`1 source)
   at System.Linq.OrderedEnumerable`1.ToList()
   at ServiceControl.CompositeViews.MessageCounting.GetAuditCountsForEndpointApi.ProcessResults(AuditCountsForEndpointContext input, QueryResult`1[] results) in /_/src/ServiceControl/CompositeViews/AuditCounts/GetAuditCountsForEndpointApi.cs:line 34
   at ServiceControl.CompositeViews.Messages.ScatterGatherApi`3.AggregateResults(TIn input, QueryResult`1[] results) in /_/src/ServiceControl/CompositeViews/Messages/ScatterGatherApi.cs:line 77
   at ServiceControl.CompositeViews.Messages.ScatterGatherApi`3.Execute(TIn input, String pathAndQuery) in /_/src/ServiceControl/CompositeViews/Messages/ScatterGatherApi.cs:line 63
   at ServiceControl.Infrastructure.Api.AuditCountApi.GetEndpointAuditCounts(String endpoint, CancellationToken token) in /_/src/ServiceControl/Infrastructure/Api/AuditCountApi.cs:line 14
   at Particular.LicensingComponent.AuditThroughput.AuditQuery.GetAuditCountForEndpoint(String endpointUrlName, CancellationToken cancellationToken) in /_/src/Particular.LicensingComponent/AuditThroughput/AuditQuery.cs:line 39
   at Particular.LicensingComponent.AuditThroughput.AuditThroughputCollectorHostedService.GatherThroughput(CancellationToken cancellationToken) in /_/src/Particular.LicensingComponent/AuditThroughput/AuditThroughputCollectorHostedService.cs:line 75
   at Particular.LicensingComponent.AuditThroughput.AuditThroughputCollectorHostedService.ExecuteAsync(CancellationToken cancellationToken) in /_/src/Particular.LicensingComponent/AuditThroughput/AuditThroughputCollectorHostedService.cs:line 35

Expected behavior

Actual behavior

Versions

  • Latest 6.3

Steps to reproduce

Not sure at this stage

Relevant log output

Additional Information

Workarounds

Possible solutions

Additional information

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions