jazida-opensource / dotenv-azure

🛠 Load environment variables from Azure's services App Configuration, Key Vault or a .env file
MIT License
10 stars 4 forks source link

Improve KeyVault errors #24

Open danielfsousa opened 4 years ago

danielfsousa commented 4 years ago

When a key vault secret is not found dotenv-azure throws the following error:

Error: Secret not found: SecretName/55f53bc304ad46f29dc059c1bf7468b4
    at new RestError (~/jazida-scripts/node_modules/@azure/core-http/lib/restError.ts:18:5)
    at ~/jazida-scripts/node_modules/@azure/core-http/lib/policies/deserializationPolicy.ts:117:27
    at Promise.propagateAslWrapper (~/jazida-scripts/node_modules/async-listener/index.js:504:23)
    at Promise.__asl_wrapper (~/jazida-scripts/node_modules/async-listener/glue.js:188:31)
    at proxyWrapper (~/jazida-scripts/node_modules/async-listener/index.js:529:23)
    at ~/jazida-scripts/node_modules/async-listener/index.js:541:70
    at ~/jazida-scripts/node_modules/async-listener/glue.js:188:31

We should create a KeyVaultError and throw after all key vault requests are completed, so we can inform all the missing secrets once.

danielfsousa commented 4 years ago

Also, if CLIENT_ID, CLIENT_SECRET and/or TENANT_ID are missing/invalid the error Request is missing a Bearer or PoP token. is thrown