From ae2b649f01b838660f2349786262c9fb63c1c3f8 Mon Sep 17 00:00:00 2001 From: Zain Budhwani Date: Wed, 11 Oct 2023 22:05:21 +0000 Subject: [PATCH] Drop sending data if panic happens --- sonic_data_client/db_client.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/sonic_data_client/db_client.go b/sonic_data_client/db_client.go index 96c0941d..935a318e 100644 --- a/sonic_data_client/db_client.go +++ b/sonic_data_client/db_client.go @@ -311,6 +311,7 @@ func (c *DbClient) PollRun(q *queue.PriorityQueue, poll chan struct{}, w *sync.W for gnmiPath, tblPaths := range c.pathG2S { val, err := tableData2TypedValue(tblPaths, nil) if err != nil { + log.V(2).Infof("Unable to create gnmi TypedValue due to err: %v", err) return } @@ -820,6 +821,9 @@ func msi2TypedValue(msi map[string]interface{}) (*gnmipb.TypedValue, error) { log.V(2).Infof("emitJSON err %s for %v", err, msi) return nil, fmt.Errorf("emitJSON err %s for %v", err, msi) } + if jv == nil { // json is nil because of potential panic happen + return nil, fmt.Errorf("emitJSON failed due to panic") + } return &gnmipb.TypedValue{ Value: &gnmipb.TypedValue_JsonIetfVal{ JsonIetfVal: jv, @@ -858,7 +862,6 @@ func tableData2TypedValue(tblPaths []tablePath, op *string) (*gnmipb.TypedValue, }}, nil } } - err := TableData2Msi(&tblPath, useKey, nil, &msi) if err != nil { return nil, err