infisical-node icon indicating copy to clipboard operation
infisical-node copied to clipboard

Only GET request should be cached and improve error handling

Open sebastianwessel opened this issue 1 year ago • 0 comments

It makes no sense to return cached responses for request of creating, updating or removing secrets if they are not successfully. I would expect, that these methods are throwing or that they are returning some (full) error object. In any case, when an action is failing, the information is lost and data is not changed as expected.

Currently, you need to do something like this:

const result = await this.client.updateSecret(secretName, configValue)
if (result.isFallback) {
   throw new Error('Unable to update secret for unknown reason')
}

Also, as always some result is returned, errors are swallowed and not visible to the consumer. At least in the returned ISecretBundle, there should be some optional error field, which contains the error.

Something like this:

const result = await this.client.updateSecret(secretName, configValue)
if (result.error) {
   console.error(result.error)
   throw new Error('Unable to update secret: ' + result.error.message )
}

sebastianwessel avatar May 29 '23 09:05 sebastianwessel