Azure-sdk-for-js: @azure/identity setting global axios defaults

Created on 22 Jan 2021  路  3Comments  路  Source: Azure/azure-sdk-for-js

  • Package Name: @azure/identity
  • Package Version: 1.2.2
  • Operating system:
  • [x] nodejs

    • version: 12.20.0

  • [ ] browser

    • name/version:

  • [] typescript

    • version:

  • Is the bug related to documentation in

Describe the bug
Use of this package seems to be overriding global axios defaults in consuming code

axios.defaults.validateStatus = () => true is being set in https://github.com/Azure/azure-sdk-for-js/blob/master/sdk/identity/identity/src/client/msalClient.ts#L165. This is set on the global axios instance thus affecting axios calls in our own code, changing the default axios behaviour on error responses

To Reproduce
Steps to reproduce the behavior:

  1. Install @azure/identity package in consuming project
  2. Install axios (v0.21.1) in consuming project
  3. Perform an axios call that returns an error response eg 500
  4. axios unexpectedly doesn't throw the error due to global defaults overriden in @azure/identity

Expected behavior
Use of this package should not override global axios settings in consuming code

Additional context
Suggested fix is to use a custom axios instance in msalClient and set defaults on that rather than the global instance

Azure.Identity Client bug customer-reported

All 3 comments

Thank you for the report. I've filed a fix for this project: https://github.com/Azure/azure-sdk-for-js/pull/13468. I've also reached out to another dependency which may have a similar issue: https://github.com/AzureAD/microsoft-authentication-library-for-js/issues/2951

@pjblakey Hello PJ, we've released Identity 1.2.3, in which we've removed all the instances where the global Axios defaults were altered. Can you test again? Please let us know if things are resolved. If so, feel free to close this issue!

Also, please let us know if we can help with anything else!

@sadasant yep have tested 1.2.3 and the issue's resolved now, thank you!

Was this page helpful?
0 / 5 - 0 ratings