Skip to content
This repository has been archived by the owner on Jul 26, 2022. It is now read-only.

Show error on missing property #87

Merged
merged 1 commit into from
Jun 6, 2019
Merged

Show error on missing property #87

merged 1 commit into from
Jun 6, 2019

Conversation

kenske
Copy link
Contributor

@kenske kenske commented Jun 6, 2019

The polling function was not outputting an error message when a property is missing from a secret. This addresses #63 .

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)
Copy link
Contributor

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.

Copy link
Contributor Author

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())
Copy link
Contributor

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)
Copy link
Contributor

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}`)

@silasbw silasbw merged commit ef8bd5f into external-secrets:master Jun 6, 2019
@kenske kenske deleted the error-on-missing-property branch June 6, 2019 16:45
@silasbw
Copy link
Contributor

silasbw commented Jun 6, 2019

@kenske we just pushed version 1.2.3 that includes your fix. Thanks for tracking down the bug and sending in a fix. 💯 🥇

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants