Export credentialUnavailableError constructor#19733
Conversation
|
We need to start with a very super clear definition of what "non-fatal" means exactly. So, I assume a network error is non-fatal because another attempt may succeed? But some EnvironmentCredential always fails if the env var doesn't exist or has a bad value? But then, what if the process adds the env var or changes the value? Then this EnvCred in the chain will now work and be used in a new client? Let's discuss this at our next scrum meeting. |
I agree that would be bad. Fortunately, the default behavior of a chain is to reuse the first successful credential for all subsequent authentications. If the chain is
No, network errors during authentication are fatal in that they cause credentials to return other error types.
This doesn't arise because only the constructor reads environment variables, and it returns an error when it doesn't find a complete set. If the configuration is complete but incorrect, the credential will attempt to authenticate--no |
This error type exists so a credential that can't acquire a token due to some non-fatal reason can signal
ChainedTokenCredentialto try another credential. For example,ManagedIdentityCredentialreturns this error type when managed identity isn't available in the runtime environment. Today, because this type isn't exported,ChainedTokenCredentialtreats all errors from custom credential implementations as fatal and therefore never tries the next credential in the chain. #19699 (comment) describes a scenario blocked by that behavior.I also updated
ChainedTokenCredentialto behave the same whether acredentialUnavailableErroris wrapped or not, so custom credentials can propagate other errors more easily.