From 780f73d970f43f100bc00ef72f8865a2f7c49ce9 Mon Sep 17 00:00:00 2001 From: priyanshi-yb Date: Mon, 3 Mar 2025 21:10:56 +0530 Subject: [PATCH] Fix: nil pointer exception while sending the callhome payload for import data to source/source-replica --- yb-voyager/cmd/importDataToSource.go | 6 ++++-- yb-voyager/cmd/importDataToSourceReplica.go | 10 ++++++---- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/yb-voyager/cmd/importDataToSource.go b/yb-voyager/cmd/importDataToSource.go index fc27566953..91214f33ab 100644 --- a/yb-voyager/cmd/importDataToSource.go +++ b/yb-voyager/cmd/importDataToSource.go @@ -98,7 +98,9 @@ func packAndSendImportDataToSourcePayload(status string, errorMsg string) { sourceDBDetails := callhome.SourceDBDetails{ DBType: tconf.TargetDBType, - DBVersion: targetDBDetails.DBVersion, + } + if targetDBDetails != nil { + sourceDBDetails.DBVersion = targetDBDetails.DBVersion } payload.SourceDBDetails = callhome.MarshalledJsonString(sourceDBDetails) @@ -112,7 +114,7 @@ func packAndSendImportDataToSourcePayload(status string, errorMsg string) { importDataPayload.Phase = importPhase - if importPhase != dbzm.MODE_SNAPSHOT { + if importPhase != dbzm.MODE_SNAPSHOT && statsReporter != nil { importDataPayload.EventsImportRate = statsReporter.EventsImportRateLast3Min importDataPayload.TotalImportedEvents = statsReporter.TotalEventsImported } diff --git a/yb-voyager/cmd/importDataToSourceReplica.go b/yb-voyager/cmd/importDataToSourceReplica.go index f8e93ac236..2a0402b84f 100644 --- a/yb-voyager/cmd/importDataToSourceReplica.go +++ b/yb-voyager/cmd/importDataToSourceReplica.go @@ -100,9 +100,11 @@ func packAndSendImportDataToSrcReplicaPayload(status string, errorMsg string) { payload.MigrationType = LIVE_MIGRATION sourceDBDetails := callhome.SourceDBDetails{ - DBType: tconf.TargetDBType, - DBVersion: targetDBDetails.DBVersion, - Role: "replica", + DBType: tconf.TargetDBType, + Role: "replica", + } + if targetDBDetails != nil { + sourceDBDetails.DBVersion = targetDBDetails.DBVersion } payload.SourceDBDetails = callhome.MarshalledJsonString(sourceDBDetails) @@ -128,7 +130,7 @@ func packAndSendImportDataToSrcReplicaPayload(status string, errorMsg string) { importDataPayload.Phase = importPhase - if importPhase != dbzm.MODE_SNAPSHOT { + if importPhase != dbzm.MODE_SNAPSHOT && statsReporter != nil { importDataPayload.EventsImportRate = statsReporter.EventsImportRateLast3Min importDataPayload.TotalImportedEvents = statsReporter.TotalEventsImported }