From 3d9afe59f58c8f0009e4573e62ede23fa04da162 Mon Sep 17 00:00:00 2001 From: Victor Baranov Date: Wed, 26 Feb 2020 18:24:19 +0300 Subject: [PATCH] Rescue for SUPPORTED_CHAINS env var parsing --- .dialyzer-ignore | 2 +- CHANGELOG.md | 1 + .../lib/block_scout_web/views/layout_view.ex | 11 ++++++++--- .../test/block_scout_web/views/layout_view_test.exs | 6 ++++++ 4 files changed, 16 insertions(+), 4 deletions(-) diff --git a/.dialyzer-ignore b/.dialyzer-ignore index 66cdf7ae08..1535f582c8 100644 --- a/.dialyzer-ignore +++ b/.dialyzer-ignore @@ -12,4 +12,4 @@ apps/explorer/lib/explorer/smart_contract/publisher_worker.ex:6: The pattern 'fa apps/explorer/lib/explorer/smart_contract/publisher_worker.ex:6: The test 5 == 'infinity' can never evaluate to 'true' lib/block_scout_web/router.ex:1 lib/phoenix/router.ex:324 -lib/block_scout_web/views/layout_view.ex:142 \ No newline at end of file +lib/block_scout_web/views/layout_view.ex:143 \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md index f68b2a5ffd..d8bb769e71 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,7 @@ - [#2834](https://github.com/poanetwork/blockscout/pull/2834) - always redirect to checksummed hash ### Fixes +- [#3027](https://github.com/poanetwork/blockscout/pull/3027) - Rescue for SUPPORTED_CHAINS env var parsing - [#3025](https://github.com/poanetwork/blockscout/pull/3025) - Fix splitting of indexer/web components setup - [#3024](https://github.com/poanetwork/blockscout/pull/3024) - Fix pool size default value in config - [#3021](https://github.com/poanetwork/blockscout/pull/3021), [#3022](https://github.com/poanetwork/blockscout/pull/3022) - Refine dev/test config diff --git a/apps/block_scout_web/lib/block_scout_web/views/layout_view.ex b/apps/block_scout_web/lib/block_scout_web/views/layout_view.ex index 723167547d..051ec77024 100644 --- a/apps/block_scout_web/lib/block_scout_web/views/layout_view.ex +++ b/apps/block_scout_web/lib/block_scout_web/views/layout_view.ex @@ -137,9 +137,14 @@ defmodule BlockScoutWeb.LayoutView do def other_networks do get_other_networks = if Application.get_env(:block_scout_web, :other_networks) do - :block_scout_web - |> Application.get_env(:other_networks) - |> Parser.parse!(%{keys: :atoms!}) + try do + :block_scout_web + |> Application.get_env(:other_networks) + |> Parser.parse!(%{keys: :atoms!}) + rescue + _ -> + [] + end else @default_other_networks end diff --git a/apps/block_scout_web/test/block_scout_web/views/layout_view_test.exs b/apps/block_scout_web/test/block_scout_web/views/layout_view_test.exs index 6ce6507c0a..0c9fafa75a 100644 --- a/apps/block_scout_web/test/block_scout_web/views/layout_view_test.exs +++ b/apps/block_scout_web/test/block_scout_web/views/layout_view_test.exs @@ -115,6 +115,12 @@ defmodule BlockScoutWeb.LayoutViewTest do } ] end + + test "get empty networks list if SUPPORTED_CHAINS is not parsed" do + Application.put_env(:block_scout_web, :other_networks, "not a valid json") + + assert LayoutView.other_networks() == [] + end end describe "main_nets/1" do