-
Notifications
You must be signed in to change notification settings - Fork 404
Show error on missing property #87
Show error on missing property #87
Conversation
The polling function was not outputting an error message when a property is missing from a secret.
@@ -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) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the pul request! Could you add a unit test for this case?
Also, it's probably better to check parsedValue[secretProperty.property]
to match the rest of the code, or even check the result on line 43 before returning.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure I understand... parsedValue[secretProperty.property]
could contain an empty value, so checking that wouldn't help with verifying if the property exists.
@@ -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()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: this._logger.error(err)
should work
@@ -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) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit
throw new Error(`Could not find property ${secretProperty.property} in ${secretProperty.key}`)
@kenske we just pushed version |
The polling function was not outputting an error message when a property is missing from a secret. This addresses #63 .