From 407ff8a1ecc04a8a09ac7317d5dea01df817f18d Mon Sep 17 00:00:00 2001 From: Will Duan Date: Mon, 27 Nov 2023 15:04:25 -0800 Subject: [PATCH] Fix nil panic (#5153) **What changed?** Add nil check when using namespaceEntry **Why?** nil panic found at edge case **How did you test it?** n/a **Potential risks** no **Is hotfix candidate?** no --- service/history/replication/raw_task_converter.go | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/service/history/replication/raw_task_converter.go b/service/history/replication/raw_task_converter.go index 6caf0a0ed47..fe892eebf45 100644 --- a/service/history/replication/raw_task_converter.go +++ b/service/history/replication/raw_task_converter.go @@ -116,8 +116,15 @@ func (c *SourceTaskConverterImpl) Convert( if clientShardID != c.clientShardKey.ShardID { return nil, nil } + var ctx context.Context + var cancel context.CancelFunc + + if namespaceEntry != nil { + ctx, cancel = newTaskContext(namespaceEntry.Name().String()) + } else { + ctx, cancel = context.WithTimeout(context.Background(), applyReplicationTimeout) + } - ctx, cancel := newTaskContext(namespaceEntry.Name().String()) defer cancel() replicationTask, err := c.historyEngine.ConvertReplicationTask(ctx, task) if err != nil {