From da0c9ddc0ef1402a9a08472a4b4e010f332d12f0 Mon Sep 17 00:00:00 2001 From: Nathan Wallace Date: Tue, 11 Nov 2025 17:58:06 +0800 Subject: [PATCH] Fix #4750: Nil pointer panic in RegisterExporters (#4769) --- pkg/initialisation/init_data.go | 4 ++++ pkg/initialisation/init_data_test.go | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/pkg/initialisation/init_data.go b/pkg/initialisation/init_data.go index 00e564503..d0b291696 100644 --- a/pkg/initialisation/init_data.go +++ b/pkg/initialisation/init_data.go @@ -46,6 +46,10 @@ func NewInitData() *InitData { func (i *InitData) RegisterExporters(exporters ...export.Exporter) *InitData { for _, e := range exporters { + // Skip nil exporters to prevent nil pointer panic + if e == nil { + continue + } if err := i.ExportManager.Register(e); err != nil { // short circuit if there is an error i.Result.Error = err diff --git a/pkg/initialisation/init_data_test.go b/pkg/initialisation/init_data_test.go index 87e73e478..3afcb729d 100644 --- a/pkg/initialisation/init_data_test.go +++ b/pkg/initialisation/init_data_test.go @@ -110,7 +110,7 @@ func TestInitData_CleanupIdempotency(t *testing.T) { // TestInitData_NilExporter tests registering nil exporters func TestInitData_NilExporter(t *testing.T) { - t.Skip("Demonstrates bug #4750 - HIGH nil pointer panic when registering nil exporter. Remove this skip in bug fix PR commit 1, then fix in commit 2.") + // t.Skip("Demonstrates bug #4750 - HIGH nil pointer panic when registering nil exporter. Remove this skip in bug fix PR commit 1, then fix in commit 2.") initData := NewInitData() // Register nil exporter - should this panic or handle gracefully?