From ef8bd5f01c5f7a23bb076bc9073b932edcff391b Mon Sep 17 00:00:00 2001 From: Kenneth Date: Thu, 6 Jun 2019 11:02:00 -0500 Subject: [PATCH] fix(logging): show error on missing property (#87) The polling function was not outputting an error message when a property is missing from a secret. --- lib/backends/kv-backend.js | 5 +++++ lib/poller.js | 3 ++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/backends/kv-backend.js b/lib/backends/kv-backend.js index 894d8503..535ddb78 100644 --- a/lib/backends/kv-backend.js +++ b/lib/backends/kv-backend.js @@ -35,6 +35,11 @@ class KVBackend extends AbstractBackend { this._logger.warn(`Failed to JSON.parse '${value}':`, err) return } + + if (!(secretProperty.property in parsedValue)) { + throw new Error('Could not find property ' + secretProperty.property + ' in ' + secretProperty.key) + } + return parsedValue[secretProperty.property] } diff --git a/lib/poller.js b/lib/poller.js index f401a38b..63ed0bcd 100644 --- a/lib/poller.js +++ b/lib/poller.js @@ -64,7 +64,8 @@ class Poller { return this._upsertKubernetesSecret({ secretDescriptor }) })) } catch (err) { - this._logger.error('failure while polling the secrets', err) + this._logger.error('failure while polling the secrets') + this._logger.error(err.toString()) } }