From a5092db9822da1b3d66156c83f7332a4854d2b1c Mon Sep 17 00:00:00 2001 From: tbjump Date: Thu, 4 May 2023 18:05:56 +0000 Subject: [PATCH] node/governor: handle type assertion error --- node/pkg/governor/governor_prices.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/node/pkg/governor/governor_prices.go b/node/pkg/governor/governor_prices.go index 361810e69..2e305d6de 100644 --- a/node/pkg/governor/governor_prices.go +++ b/node/pkg/governor/governor_prices.go @@ -156,8 +156,12 @@ func (gov *ChainGovernor) queryCoinGecko() error { if exists { // If a price is not set in CoinGecko, they return an empty entry. Treat that as a zero price. var price float64 - - m := data.(map[string]interface{}) + m, ok := data.(map[string]interface{}) + if !ok { + gov.logger.Error("failed to parse CoinGecko response, reverting to configured price for this token", zap.String("coinGeckoId", coinGeckoId)) + // By continuing, we leave this one in the local map so the price will get reverted below. + continue + } if len(m) != 0 { var ok bool price_, ok := m["usd"]