From db75e5d605a15e371a61f9c3d6dbc6c29b8c3572 Mon Sep 17 00:00:00 2001 From: Scott Twiname Date: Tue, 17 Oct 2023 11:46:26 +1300 Subject: [PATCH 1/2] Catch error with dictionary validation, this can happen if the dictionary returns invalid metadata --- .../src/indexer/dictionary.service.ts | 31 +++++++++++-------- 1 file changed, 18 insertions(+), 13 deletions(-) diff --git a/packages/node-core/src/indexer/dictionary.service.ts b/packages/node-core/src/indexer/dictionary.service.ts index 68a8930adc..fbd08edeaa 100644 --- a/packages/node-core/src/indexer/dictionary.service.ts +++ b/packages/node-core/src/indexer/dictionary.service.ts @@ -427,22 +427,27 @@ export class DictionaryService { private dictionaryValidation(metaData?: MetaData, startBlockHeight?: number): boolean { const validate = (): boolean => { - if (!metaData) { - return false; - } - // Some dictionaries rely on chain others rely on genesisHash - if (!this.validateChainMeta(metaData)) { - logger.error( - 'The dictionary that you have specified does not match the chain you are indexing, it will be ignored. Please update your project manifest to reference the correct dictionary' - ); - return false; - } + try { + if (!metaData) { + return false; + } + // Some dictionaries rely on chain others rely on genesisHash + if (!this.validateChainMeta(metaData)) { + logger.error( + 'The dictionary that you have specified does not match the chain you are indexing, it will be ignored. Please update your project manifest to reference the correct dictionary' + ); + return false; + } - if (startBlockHeight !== undefined && metaData.lastProcessedHeight < startBlockHeight) { - logger.warn(`Dictionary indexed block is behind current indexing block height`); + if (startBlockHeight !== undefined && metaData.lastProcessedHeight < startBlockHeight) { + logger.warn(`Dictionary indexed block is behind current indexing block height`); + return false; + } + return true; + } catch (e: any) { + logger.error(e, 'Unable to validate dictionary metadata'); return false; } - return true; }; const valid = validate(); From 4ee74406bbe7f804639e7f5c7b7d9a4b581081aa Mon Sep 17 00:00:00 2001 From: Scott Twiname Date: Tue, 17 Oct 2023 13:21:15 +1300 Subject: [PATCH 2/2] Update changelog --- packages/node-core/CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/packages/node-core/CHANGELOG.md b/packages/node-core/CHANGELOG.md index c6ecb5176b..8986dc30b7 100644 --- a/packages/node-core/CHANGELOG.md +++ b/packages/node-core/CHANGELOG.md @@ -5,6 +5,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). ## [Unreleased] +### Fixed +- Dictionary validation error causing application exit (#2101) ## [6.0.2] - 2023-10-12 ### Fixed