azure-pipelines-tasks: npm Authenticate task failing TypeError: Cannot read property 'retrieveSecret' of undefined

Troubleshooting

Done

Environment

  • Server - VSTS or TFS on-premises?

N/A

  • Agent - Hosted or Private:

N/A

Issue Description

Running npm authenticate finds the npmrc file but fails to run saying TypeError: Cannot read property 'retrieveSecret' of undefined

As a note, this worked without any changes on Friday.

Error logs

2018-04-02T14:00:59.7935943Z ##[debug]Evaluating condition for step: ‘npm Authenticate’ 2018-04-02T14:00:59.7935943Z ##[debug]Evaluating: succeeded() 2018-04-02T14:00:59.7935943Z ##[debug]Evaluating succeeded: 2018-04-02T14:00:59.7935943Z ##[debug]=> (Boolean) True 2018-04-02T14:00:59.7935943Z ##[debug]Expanded: True 2018-04-02T14:00:59.7935943Z ##[debug]Result: True 2018-04-02T14:00:59.7935943Z ##[section]Starting: npm Authenticate 2018-04-02T14:00:59.7935943Z ============================================================================== 2018-04-02T14:00:59.7935943Z Task : npm Authenticate (for task runners) 2018-04-02T14:00:59.7935943Z Description : Don’t use this task if you’re also using the npm task. Provides npm credentials to an .npmrc file in your repository for the scope of the build. This enables npm task runners like Gulp and Grunt to authenticate with private registries. 2018-04-02T14:00:59.7935943Z Version : 0.0.1 2018-04-02T14:00:59.7935943Z Author : Microsoft Corporation 2018-04-02T14:00:59.7935943Z Help : 2018-04-02T14:00:59.7935943Z ============================================================================== 2018-04-02T14:01:00.0436262Z ##[debug]agent.workFolder=F:\agent_work 2018-04-02T14:01:00.0436262Z ##[debug]loading inputs and endpoints 2018-04-02T14:01:00.0436262Z ##[debug]loading ENDPOINT_AUTH_PARAMETER_SYSTEMVSSCONNECTION_ACCESSTOKEN 2018-04-02T14:01:00.0436262Z ##[debug]loading ENDPOINT_AUTH_SCHEME_SYSTEMVSSCONNECTION 2018-04-02T14:01:00.0436262Z ##[debug]loading ENDPOINT_AUTH_SYSTEMVSSCONNECTION 2018-04-02T14:01:00.0436262Z ##[debug]loading INPUT_WORKINGFILE 2018-04-02T14:01:00.0436262Z ##[debug]loading SECRET_TSBLOBKEY 2018-04-02T14:01:00.0436262Z ##[debug]loaded 5 2018-04-02T14:01:00.2623836Z ##[debug]check path : F:\agent_work_tasks\npmAuthenticate_ad884ca2-732e-4b85-b2d3-ed71bcbd2788\0.0.1\task.json 2018-04-02T14:01:00.2623836Z ##[debug]set resource file to: F:\agent_work_tasks\npmAuthenticate_ad884ca2-732e-4b85-b2d3-ed71bcbd2788\0.0.1\task.json 2018-04-02T14:01:00.2623836Z ##[debug]system.culture=en-US 2018-04-02T14:01:00.2623836Z ##[debug]workingFile=<FILE_PATH>.npmrc 2018-04-02T14:01:00.2623836Z Adding authentication to the .npmrc file at F:\agent_work\40\s<FILE_PATH>.npmrc 2018-04-02T14:01:00.2623836Z ##[debug]SAVE_NPMRC_PATH=undefined 2018-04-02T14:01:00.2623836Z ##[debug]Agent.BuildDirectory=F:\agent_work\40 2018-04-02T14:01:00.2623836Z ##[debug]testing directory ‘F:\agent_work\40\npmAuthenticate’ 2018-04-02T14:01:00.2623836Z ##[debug]set SAVE_NPMRC_PATH=F:\agent_work\40\npmAuthenticate\zI982M 2018-04-02T14:01:00.2623836Z ##[debug]Processed: ##vso[task.setvariable variable=SAVE_NPMRC_PATH;issecret=false;]F:\agent_work\40\npmAuthenticate\zI982M 2018-04-02T14:01:00.2623836Z ##[debug]set NPM_AUTHENTICATE_TEMP_DIRECTORY=F:\agent_work\40\npmAuthenticate 2018-04-02T14:01:00.2623836Z ##[debug]Processed: ##vso[task.setvariable variable=NPM_AUTHENTICATE_TEMP_DIRECTORY;issecret=false;]F:\agent_work\40\npmAuthenticate 2018-04-02T14:01:00.2779842Z ##[warning]Resource file haven't set, can't find loc string for key: SavingFile 2018-04-02T14:01:00.2779842Z ##[debug]Processed: ##vso[task.issue type=warning;]Resource file haven't set, can't find loc string for key: SavingFile 2018-04-02T14:01:00.2779842Z ##[debug]SavingFile F:\agent_work\40\s<FILE_PATH>.npmrc 2018-04-02T14:01:00.2779842Z ##[debug]customEndpoint=null 2018-04-02T14:01:00.2779842Z ##[debug]Npm.PackagingCollectionUrl=undefined 2018-04-02T14:01:00.2779842Z ##[debug]System.TeamFoundationCollectionUri=https://<VSTS_URL>.visualstudio.com/ 2018-04-02T14:01:00.2936119Z ##[warning]Resource file haven't set, can't find loc string for key: FoundLocalRegistries 2018-04-02T14:01:00.2936119Z ##[debug]Processed: ##vso[task.issue type=warning;]Resource file haven't set, can't find loc string for key: FoundLocalRegistries 2018-04-02T14:01:00.2936119Z ##[debug]FoundLocalRegistries 1 2018-04-02T14:01:00.2936119Z ##[debug]Agent.BuildDirectory=F:\agent_work\40 2018-04-02T14:01:00.2936119Z ##[debug]testing directory ‘F:\agent_work\40\npm’ 2018-04-02T14:01:00.2936119Z ##[debug]testing directory ‘F:\agent_work\40’ 2018-04-02T14:01:00.2936119Z ##[debug]mkdir ‘F:\agent_work\40\npm’ 2018-04-02T14:01:00.2936119Z ##[debug]rm -rf F:\agent_work\40\npm 2018-04-02T14:01:00.2936119Z ##[debug]removing directory 2018-04-02T14:01:00.2936119Z ##[debug]task result: Failed 2018-04-02T14:01:00.2936119Z ##[error]TypeError: Cannot read property ‘retrieveSecret’ of undefined 2018-04-02T14:01:00.2936119Z ##[debug]Processed: ##vso[task.issue type=error;]TypeError: Cannot read property ‘retrieveSecret’ of undefined 2018-04-02T14:01:00.2936119Z ##[debug]Processed: ##vso[task.complete result=Failed;]TypeError: Cannot read property ‘retrieveSecret’ of undefined 2018-04-02T14:01:00.2936119Z ##[section]Finishing: npm Authenticate

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Comments: 31 (2 by maintainers)

Most upvoted comments

@shelmobd @SESA18621 I found another thread in the developer community, seems the issue is being investigated. https://developercommunity.visualstudio.com/t/npmAuthenticate0-Failing-for-version--0/10249182?q=npmauthenticate

The issue seems to be occurring again on the VSTS pipeline I am getting ##[error]TypeError: Cannot read properties of undefined (reading ‘retrieveSecret’)

I am also seeing the issue with Helm charts. It appears to be related to having TLS enabled for communication between Helm and Tiller. If this isn’t the right place to post this, can someone please point me in the right direction? This is currently block deployments for us. Thanks!

FYI to folks. We have a fix for the above task. Will be trying to hotfix that now. Also verifying which other tasks this might be affecting. Stay tuned.

I fought with this issue quite a bit today and i think i figured out the key to reproducing this issue @jmyersmsft and @justinmwarner

If you import the vsts-task-tool-lib/tool before vsts-task-lib/task then this error is reproduced. If i switch the order to load vsts-task-lib/task first then the error goes away.

I noticed that the vsts-task-tool-lib/tool module takes a dependency on vsts-task-lib. Since there is some global state being kept within the vsts-task-lib module (global['_vsts_task_lib_loaded']) then i suspected this may be causing the state data to not get loaded properly if another dependency invoked the module. To test this, i flipped the import order and it resolved the issue. I also tried flipping the order back and i was able to recreate the issue again.